Skip to content

Commit

Permalink
check clean json structure
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-kurmanov committed Oct 27, 2023
1 parent 92bf5f1 commit bc1e548
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/question_comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
17 changes: 17 additions & 0 deletions tests/jsonobjecttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
};
}
});
8 changes: 4 additions & 4 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit bc1e548

Please sign in to comment.