diff --git a/src/OptionList.tsx b/src/OptionList.tsx index 9de61eae5..329269aaf 100644 --- a/src/OptionList.tsx +++ b/src/OptionList.tsx @@ -23,6 +23,10 @@ export interface RefOptionListProps { scrollTo?: (index: number) => void; } +function isTitleType(content: any) { + return typeof content === 'string' || typeof content === 'number'; +} + /** * Using virtual list of option display. * Will fallback to dom if use customize render. @@ -272,8 +276,13 @@ const OptionList: React.ForwardRefRenderFunction +
{label !== undefined ? label : key}
); @@ -301,10 +310,7 @@ const OptionList: React.ForwardRefRenderFunction { wrapper.find('input').simulate('change', { target: { value: '1' } }); expect(wrapper.find('List').props().data).toHaveLength(2); }); + + describe('group title', () => { + it('label as title', () => { + const wrapper = mount( + , + ); + + expect(wrapper.find('.rc-select-item-group').prop('title')).toEqual('zombiej'); + }); + + it('customize title', () => { + const wrapper = mount( + , + ); + + expect(wrapper.find('.rc-select-item-group').prop('title')).toEqual('bamboo'); + }); + }); }); diff --git a/tests/__snapshots__/Select.test.tsx.snap b/tests/__snapshots__/Select.test.tsx.snap index 0b1956884..70f8a1a05 100644 --- a/tests/__snapshots__/Select.test.tsx.snap +++ b/tests/__snapshots__/Select.test.tsx.snap @@ -534,6 +534,7 @@ exports[`Select.Basic render renders dropdown correctly 1`] = ` >
manager
@@ -584,6 +585,7 @@ exports[`Select.Basic render renders dropdown correctly 1`] = `
engineer
diff --git a/tests/__snapshots__/Tags.test.tsx.snap b/tests/__snapshots__/Tags.test.tsx.snap index 170bade29..f0273f1ff 100644 --- a/tests/__snapshots__/Tags.test.tsx.snap +++ b/tests/__snapshots__/Tags.test.tsx.snap @@ -142,6 +142,7 @@ exports[`Select.Tags OptGroup renders correctly 1`] = ` >
Manager
@@ -170,6 +171,7 @@ exports[`Select.Tags OptGroup renders correctly 1`] = `
Engineer