created tests for IntentDetails component ; improved input validators

This commit is contained in:
GotPPay
2018-04-04 21:59:13 +02:00
parent 4d2cf52e4c
commit 275ab2e9b1
4 changed files with 1189 additions and 18 deletions

View File

@@ -157,14 +157,14 @@ class IntentDetails extends Component {
}
handleQuestionEdit (e, index) {
if (e.length === QUESTION_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e)) return;
if (e.length >= QUESTION_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e)) return;
let newIntent = this.state.intent;
newIntent.questions[index] = e;
this.setState ({intent: newIntent});
}
handleIntentExplanationEdit (e, index) {
if (e.length === INTENT_EXPLANATION_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e))
if (e.length >= INTENT_EXPLANATION_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e))
return;
let newIntent = this.state.intent;
newIntent.intentExplanation = e;
@@ -172,21 +172,21 @@ class IntentDetails extends Component {
}
handleAnswerEdit (e) {
if (e.length === ANSWER_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e)) return;
if (e.length >= ANSWER_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e)) return;
let newIntent = this.state.intent;
newIntent.answer = e;
this.setState ({intent: newIntent});
}
handleAnswerSourceEdit (e) {
if (e.length === ANSWER_MAX_LENGTH) return;
if (e.length >= ANSWER_MAX_LENGTH) return;
let newIntent = this.state.intent;
newIntent.externalAnswerSource = e;
this.setState ({intent: newIntent});
}
handleIntentNameEdit (e) {
if (e.length === INTENT_NAME_MAX_LENGTH || !/^[a-z]*$/i.test (e)) return;
if (e.length >= INTENT_NAME_MAX_LENGTH || !/^[a-z]*$/i.test (e)) return;
let newIntent = this.state.intent;
newIntent.intentName = e;
this.setState ({intent: newIntent});