From e136b3d8228ec69d681dbdc1a00dc0c237b43bd6 Mon Sep 17 00:00:00 2001 From: Chuanbao Lu Date: Tue, 24 Dec 2024 21:35:47 -0500 Subject: [PATCH] 35280 add unit test --- .../__tests__/ColumnSelectorUtils.test.tsx | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/packages/common-ui/lib/column-selector/__tests__/ColumnSelectorUtils.test.tsx b/packages/common-ui/lib/column-selector/__tests__/ColumnSelectorUtils.test.tsx index 46ae6383f..e6a21b98c 100644 --- a/packages/common-ui/lib/column-selector/__tests__/ColumnSelectorUtils.test.tsx +++ b/packages/common-ui/lib/column-selector/__tests__/ColumnSelectorUtils.test.tsx @@ -249,6 +249,81 @@ describe("ColumnSelectorUtils", () => { }) ).toEqual("assemblages.name"); }); + + it("Generate column functions path", () => { + expect( + generateColumnPath({ + indexMapping: { + label: "columnFunction", + value: "columnFunction", + path: "columnFunction", + hideField: false, + type: "columnFunction", + dynamicField: { + type: "columnFunction", + label: "columnFunction", + path: "" + }, + containsSupport: false, + distinctTerm: false, + keywordMultiFieldSupport: false, + keywordNumericSupport: false, + optimizedPrefix: false, + endsWithSupport: false + } + }) + ).toEqual("columnFunction"); + + expect( + generateColumnPath({ + indexMapping: { + label: "columnFunction", + value: "columnFunction", + path: "columnFunction", + hideField: false, + type: "columnFunction", + dynamicField: { + type: "columnFunction", + label: "columnFunction", + path: "" + }, + containsSupport: false, + distinctTerm: false, + keywordMultiFieldSupport: false, + keywordNumericSupport: false, + optimizedPrefix: false, + endsWithSupport: false + }, + dynamicFieldValue: + '{"function1":{"functionName":"CONCAT","params":[{"label":"barcode","value":"data.attributes.barcode","hideField":false,"type":"text","path":"data.attributes","keywordMultiFieldSupport":true,"keywordNumericSupport":false,"optimizedPrefix":false,"containsSupport":false,"endsWithSupport":false},{"label":"createdBy","value":"data.attributes.createdBy","hideField":false,"type":"text","path":"data.attributes","keywordMultiFieldSupport":true,"keywordNumericSupport":false,"optimizedPrefix":false,"containsSupport":false,"endsWithSupport":false}]}}' + }) + ).toEqual("columnFunction/function1/CONCAT/barcode+createdBy"); + + expect( + generateColumnPath({ + indexMapping: { + label: "columnFunction", + value: "columnFunction", + path: "columnFunction", + hideField: false, + type: "columnFunction", + dynamicField: { + type: "columnFunction", + label: "columnFunction", + path: "" + }, + containsSupport: false, + distinctTerm: false, + keywordMultiFieldSupport: false, + keywordNumericSupport: false, + optimizedPrefix: false, + endsWithSupport: false + }, + dynamicFieldValue: + '{"function2":{"functionName":"CONVERT_COORDINATES_DD"}}' + }) + ).toEqual("columnFunction/function2/CONVERT_COORDINATES_DD"); + }); }); describe("parseRelationshipNameFromType", () => {