Skip to content

Commit

Permalink
Rename functions
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Aug 21, 2023
1 parent fef16e7 commit a7e8124
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,12 @@ export class Base {
const locStr = this.localizableStrings ? this.localizableStrings[name] : undefined;
if(locStr) return locStr.text;
if (defaultValue != null) return defaultValue;
const propDefaultValue = this.getPropertyDefaultValue(name);
const propDefaultValue = this.getDefaultPropertyValue(name);
if(propDefaultValue !== undefined) return propDefaultValue;
}
return res;
}
public getPropertyDefaultValue(name: string): any {
public getDefaultPropertyValue(name: string): any {
const prop = this.getPropertyByName(name);
if(!prop || prop.isCustom && this.isCreating) return undefined;
const dValue = prop.defaultValue;
Expand All @@ -486,8 +486,8 @@ export class Base {
if (prop.isCustom && !!prop.onGetValue) return prop.onGetValue(this);
return undefined;
}
public hasPropertyDefaultValue(name: string): boolean {
return this.getPropertyDefaultValue(name) !== undefined;
public hasDefaultPropertyValue(name: string): boolean {
return this.getDefaultPropertyValue(name) !== undefined;
}
public resetPropertyValue(name: string): void {
this.setPropertyValue(name, undefined);
Expand Down
10 changes: 5 additions & 5 deletions tests/basetests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,16 +696,16 @@ QUnit.test("Subscribe localizable property", function (assert) {
assert.equal(base4.propC, "localizable value");
assert.equal(updaterCallCount1, 2, "update called - localizable value");
});
QUnit.test("base.hasPropertyDefaultValue, base.getPropertyDefaultValue and base.resetPropertyValue()", function (assert) {
QUnit.test("base.hasDefaultPropertyValue, base.getDefaultPropertyValue and base.resetPropertyValue()", function (assert) {
const question = new QuestionTextModel("q1");
assert.equal(question.hasPropertyDefaultValue("width"), false, "question.width has no default value");
assert.notOk(question.getPropertyDefaultValue("width"), "question.width default value is undefined");
assert.equal(question.hasDefaultPropertyValue("width"), false, "question.width has no default value");
assert.notOk(question.getDefaultPropertyValue("width"), "question.width default value is undefined");
question.width = "200px";
question.resetPropertyValue("width");
assert.notOk(question.width, "width property value is empty");

assert.equal(question.hasPropertyDefaultValue("minWidth"), true, "question.minWidth has default value");
assert.ok(question.getPropertyDefaultValue("minWidth"), "question.minWidth default value is 300px");
assert.equal(question.hasDefaultPropertyValue("minWidth"), true, "question.minWidth has default value");
assert.ok(question.getDefaultPropertyValue("minWidth"), "question.minWidth default value is 300px");
question.minWidth = "200px";
assert.equal(question.minWidth, "200px", "minWidth property is set to 200px");
question.resetPropertyValue("minWidth");
Expand Down

0 comments on commit a7e8124

Please sign in to comment.