Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Nov 2, 2024
1 parent 308dd10 commit aa37501
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/survey-creator-core/src/creator-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2140,24 +2140,26 @@ export class SurveyCreatorModel extends Base
if (!value) {
this.initSurveyWithJSON(undefined, clearState);
} else {
let jsonText = trustJSON ? JSON.parse(value) : undefined;
let jsonValue = trustJSON ? this.parseJSON(value) : undefined;
if(!trustJSON) {
const textWorker = new SurveyTextWorker(value);
if(textWorker.isJsonCorrect) {
jsonText = value;
jsonValue = this.parseJSON(value);
}
else if(!!textWorker.survey) {
jsonText = textWorker.survey.toJSON();
jsonValue = textWorker.survey.toJSON();
}
}
if (!!jsonText) {
this.initSurveyWithJSON(jsonText, clearState);
if (!!jsonValue) {
this.initSurveyWithJSON(jsonValue, clearState);
} else {
this.viewType = "editor";
}
}
}

private parseJSON(val: string): any {
return new SurveyJSON5().parse(val);
}
/**
* A survey JSON schema as a string.
*
Expand Down

0 comments on commit aa37501

Please sign in to comment.