diff --git a/src/utils/valueUtil.ts b/src/utils/valueUtil.ts index afafbf63..ea332015 100644 --- a/src/utils/valueUtil.ts +++ b/src/utils/valueUtil.ts @@ -52,9 +52,6 @@ export function flattenOptions { - - const label = data[isGroupOption ? groupLabel : fieldLabel]; - if (isGroupOption || !(fieldOptions in data)) { const value = data[fieldValue]; @@ -63,11 +60,11 @@ export function flattenOptions { 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,34 +123,49 @@ describe('Select.Basic', () => { const { container: containerFirst } = testingRender( , ); const { container: containerThird } = testingRender( - , ); // these generate the same snapshots - expect(containerFirst).toMatchSnapshot(); - expect(containerSecond).toMatchSnapshot(); - expect(containerThird).toMatchSnapshot(); + expect(containerFirst.querySelector('.rc-virtual-list')).toMatchSnapshot(); + expect(containerSecond.querySelector('.rc-virtual-list')).toMatchSnapshot(); + expect(containerThird.querySelector('.rc-virtual-list')).toMatchSnapshot(); }); }); + it('item label should be the same as user enter when set groupLabel', () => { + const { container } = testingRender( + diff --git a/tests/__snapshots__/Select.test.tsx.snap b/tests/__snapshots__/Select.test.tsx.snap index 4e27a106..a11de50a 100644 --- a/tests/__snapshots__/Select.test.tsx.snap +++ b/tests/__snapshots__/Select.test.tsx.snap @@ -434,142 +434,142 @@ exports[`Select.Basic render renders role prop correctly 1`] = ` `; exports[`Select.Basic render should support fieldName 1`] = ` -
+
-
- +
- - - +
+ groupLabel +
+
+
+ label +
+
+
-
`; exports[`Select.Basic render should support fieldName 2`] = ` -
+
-
- +
- - - +
+ groupLabel +
+
+
+ label +
+
+
-
`; exports[`Select.Basic render should support fieldName 3`] = ` -
+
-
- +
- - - +
+ groupLabel +
+
+
+ label +
+
+
-
`;