Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Check clean JSON structure #7249

Merged
merged 2 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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