From 685a3dcf308f2557c5cc082e00c534ff463989ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=8B?= Date: Fri, 19 May 2023 11:51:10 +0800 Subject: [PATCH] fix: groupLabel --- src/utils/valueUtil.ts | 2 +- tests/Select.test.tsx | 21 +-- tests/__snapshots__/Select.test.tsx.snap | 228 ++++++++++++++++++++++- 3 files changed, 229 insertions(+), 22 deletions(-) diff --git a/src/utils/valueUtil.ts b/src/utils/valueUtil.ts index afafbf63..45db446f 100644 --- a/src/utils/valueUtil.ts +++ b/src/utils/valueUtil.ts @@ -53,7 +53,7 @@ export function flattenOptions { - const label = data[isGroupOption ? groupLabel : fieldLabel]; + const label = data[isGroupOption ? fieldLabel : groupLabel]; if (isGroupOption || !(fieldOptions in data)) { const value = data[fieldValue]; diff --git a/tests/Select.test.tsx b/tests/Select.test.tsx index 0be3d330..fb9b793b 100644 --- a/tests/Select.test.tsx +++ b/tests/Select.test.tsx @@ -107,13 +107,13 @@ describe('Select.Basic', () => { it('should support fieldName', () => { // groupLabel > fieldNames > self-label - function genOpts(OptLabelName) { + function genOpts(OptLabelName, groupLabel) { return [ { - groupLabel: 'Manager', + [groupLabel]: 'groupLabel', options: [ { - data: 'value', + value: 'value', [OptLabelName]: 'label', }, ], @@ -123,25 +123,22 @@ describe('Select.Basic', () => { const { container: containerFirst } = testingRender( , ); const { container: containerThird } = testingRender( - , ); // these generate the same snapshots diff --git a/tests/__snapshots__/Select.test.tsx.snap b/tests/__snapshots__/Select.test.tsx.snap index 4e27a106..daf7ffd2 100644 --- a/tests/__snapshots__/Select.test.tsx.snap +++ b/tests/__snapshots__/Select.test.tsx.snap @@ -436,7 +436,7 @@ exports[`Select.Basic render renders role prop correctly 1`] = ` exports[`Select.Basic render should support fieldName 1`] = `
+
+
+
+ +
+
+
+
+
+ groupLabel +
+
+
+ label +
+
+
+
+
+
+
+