-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8880 from surveyjs/bug/8879-Comment-displays-unde…
…fined-when-resetting-value A Comment displays undefined when resetting the value
- Loading branch information
Showing
3 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { SurveyModel } from "../src/survey"; | ||
import { QuestionCommentModel } from "../src/question_comment"; | ||
|
||
export default QUnit.module("Comment question"); | ||
|
||
QUnit.test("A Comment displays undefined when resetting the value", function (assert) { | ||
let json = { | ||
"elements": [ | ||
{ | ||
"type": "comment", | ||
"name": "billing-address", | ||
"title": "Billing address", | ||
"rows": 2 | ||
}, | ||
{ | ||
"type": "boolean", | ||
"name": "shipping-same-as-billing", | ||
"title": "Shipping address same as billing", | ||
"defaultValue": "true" | ||
}, | ||
{ | ||
"type": "comment", | ||
"name": "shipping-address", | ||
"title": "Shipping address", | ||
"enableIf": "{shipping-same-as-billing} = false", | ||
"resetValueIf": "{shipping-same-as-billing} = false", | ||
"setValueIf": "{shipping-same-as-billing} = true", | ||
"setValueExpression": "{billing-address}", | ||
"rows": 2 | ||
} | ||
], | ||
"showQuestionNumbers": "off", | ||
"textUpdateMode": "onTyping" | ||
}; | ||
let survey = new SurveyModel(json); | ||
let comment1 = survey.getQuestionByName("billing-address") as QuestionCommentModel; | ||
let comment2 = survey.getQuestionByName("shipping-address") as QuestionCommentModel; | ||
let boolQuestion = survey.getQuestionByName("shipping-same-as-billing"); | ||
const textArea1 = document.createElement("textarea"); | ||
const textArea2 = document.createElement("textarea"); | ||
comment1.textAreaModel.setElement(textArea1); | ||
comment2.textAreaModel.setElement(textArea2); | ||
|
||
assert.equal(comment1.value, undefined, "commnet 1 value #1"); | ||
assert.equal(comment2.value, undefined, "commnet 2 value #1"); | ||
assert.equal(boolQuestion.value, true, "boolQuestion value #1"); | ||
assert.equal(textArea1.value, "", "textArea 1 value #1"); | ||
assert.equal(textArea2.value, "", "textArea 2 value #1"); | ||
|
||
comment1.value = "test"; | ||
assert.equal(comment1.value, "test", "commnet 1 value #2"); | ||
assert.equal(comment2.value, "test", "commnet 2 value #2"); | ||
assert.equal(boolQuestion.value, true, "boolQuestion value #2"); | ||
assert.equal(textArea1.value, "test", "textArea 1 value #2"); | ||
assert.equal(textArea2.value, "test", "textArea 2 value #2"); | ||
|
||
boolQuestion.value = false; | ||
assert.equal(comment1.value, "test", "commnet 1 value #3"); | ||
assert.equal(comment2.value, undefined, "commnet 2 value #3"); | ||
assert.equal(boolQuestion.value, false, "boolQuestion value #3"); | ||
assert.equal(textArea1.value, "test", "textArea 1 value #3"); | ||
assert.equal(textArea2.value, "", "textArea 2 value #3"); | ||
|
||
textArea1.remove(); | ||
textArea2.remove(); | ||
}); |