From cd40e32855b739437af135c9a84912e081be2acc Mon Sep 17 00:00:00 2001 From: Andrew Telnov Date: Mon, 5 Feb 2024 14:17:02 +0200 Subject: [PATCH] Allow to set empty string to displayName property attribute --- src/jsonobject.ts | 2 +- tests/jsonobjecttests.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/jsonobject.ts b/src/jsonobject.ts index 33afe3b406..c91a8bfa10 100644 --- a/src/jsonobject.ts +++ b/src/jsonobject.ts @@ -819,7 +819,7 @@ export class JsonMetadataClass { if (!Helpers.isValueEmpty(propInfo.maxLength)) { prop.maxLength = propInfo.maxLength; } - if (!Helpers.isValueEmpty(propInfo.displayName)) { + if (propInfo.displayName !== undefined) { prop.displayName = propInfo.displayName; } if (!Helpers.isValueEmpty(propInfo.category)) { diff --git a/tests/jsonobjecttests.ts b/tests/jsonobjecttests.ts index d1215f4bf9..a164ea56e1 100644 --- a/tests/jsonobjecttests.ts +++ b/tests/jsonobjecttests.ts @@ -3264,3 +3264,16 @@ QUnit.test("Test showInMultipleColumns prop visibility", function (assert) { assert.ok(prop, "property is here"); assert.equal(prop.isVisible("", column), true, "column is visible"); }); +QUnit.test("Versions & alternative name", function (assert) { + const prop1 = Serializer.addProperty("question", { name: "testProperty1", displayName: "" }); + const prop2 = Serializer.addProperty("question", { name: "testProperty2", displayName: undefined }); + const prop3 = Serializer.addProperty("question", { name: "testProperty3" }); + + assert.strictEqual(prop1.displayName, "", "prop1"); + assert.strictEqual(prop2.displayName, undefined, "prop2"); + assert.strictEqual(prop3.displayName, undefined, "prop3"); + + Serializer.removeProperty("question", "testProperty1"); + Serializer.removeProperty("question", "testProperty2"); + Serializer.removeProperty("question", "testProperty3"); +});