diff --git a/src/question_comment.ts b/src/question_comment.ts index 453678f58e..f12a4d4f11 100644 --- a/src/question_comment.ts +++ b/src/question_comment.ts @@ -60,13 +60,16 @@ export class QuestionCommentModel extends QuestionTextBase { * @see autoGrow */ public get allowResize(): boolean { - return this.getPropertyValue("allowResize") && (this.survey && this.survey.allowResizeComment); + return this.getPropertyValue("allowResize"); } public set allowResize(val: boolean) { this.setPropertyValue("allowResize", val); } + public get renderedAllowResize(): boolean { + return this.allowResize && (this.survey && this.survey.allowResizeComment); + } public get resizeStyle() { - return this.allowResize ? "both" : "none"; + return this.renderedAllowResize ? "both" : "none"; } public getType(): string { return "comment"; diff --git a/tests/jsonobjecttests.ts b/tests/jsonobjecttests.ts index dd18a33f2e..d67a351807 100644 --- a/tests/jsonobjecttests.ts +++ b/tests/jsonobjecttests.ts @@ -3015,4 +3015,21 @@ QUnit.test("defaultValue for matrix rowTitleWidth and columnMinWidth properties" assert.equal(matrix.columnMinWidth, "220px", "columnMinWidth"); Serializer.findProperty("matrix", "rowTitleWidth").defaultValue = undefined; Serializer.findProperty("matrix", "columnMinWidth").defaultValue = undefined; +}); + +QUnit.test("Check that .toJSON returns clean structure for all question types", function (assert) { + const name = "q"; + const etalon = { name }; + const classes = Serializer["classes"]; + + for (const prop in classes) { + const cls = classes[prop]; + const qModel: any = Serializer.createClass(cls.name); + if (!!qModel) { + qModel.name = name; + if (qModel.isQuestion && qModel.getType() === cls.name) { + assert.deepEqual(qModel.toJSON(), etalon, `JSON for ${cls.name} is clean`); + } + } + } }); \ No newline at end of file diff --git a/tests/surveytests.ts b/tests/surveytests.ts index e20824e499..ab3d0a6f44 100644 --- a/tests/surveytests.ts +++ b/tests/surveytests.ts @@ -15044,12 +15044,12 @@ QUnit.test("survey.allowResizeComment", function (assert) { let comment2 = survey.getQuestionByName("comment2"); assert.equal(survey.allowResizeComment, false); - assert.equal(comment1.allowResize, false); - assert.equal(comment2.allowResize, false); + assert.equal(comment1.renderedAllowResize, false); + assert.equal(comment2.renderedAllowResize, false); survey.allowResizeComment = true; - assert.equal(comment1.allowResize, true); - assert.equal(comment2.allowResize, false); + assert.equal(comment1.renderedAllowResize, true); + assert.equal(comment2.renderedAllowResize, false); }); QUnit.test("utils.increaseHeightByContent", assert => { let element = {