diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cc5fc111a..1b78fec3c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [ master ] + branches: [ 14.1.x ] # antd@4-stable pull_request: - branches: [ master ] + branches: [ 14.1.x ] jobs: setup: diff --git a/docs/examples/single.tsx b/docs/examples/single.tsx index d23188b27..5afce64f2 100644 --- a/docs/examples/single.tsx +++ b/docs/examples/single.tsx @@ -60,14 +60,13 @@ class Test extends React.Component {

Single Select

-
+
, ); - - const inputSpy = jest.spyOn(wrapper2.find('input').instance(), 'focus' as any); - - wrapper2.find('.rc-select-selection-placeholder').simulate('mousedown'); - wrapper2.find('.rc-select-selection-placeholder').simulate('click'); + const inputSpy = jest.spyOn(wrapper.find('input').instance(), 'focus' as any); + wrapper.find('.rc-select-selection-placeholder').simulate('mousedown'); + wrapper.find('.rc-select-selection-placeholder').simulate('click'); expect(inputSpy).toHaveBeenCalled(); }); }); @@ -816,19 +814,6 @@ describe('Select.Basic', () => { expectOpen(wrapper, false); }); - it('focus input when placeholder is clicked', () => { - const wrapper = mount( - , - ); - - const focusSpy = jest.spyOn(wrapper.find('input').instance(), 'focus' as any); - wrapper.find('.rc-select-selection-placeholder').simulate('mousedown'); - wrapper.find('.rc-select-selection-placeholder').simulate('click'); - expect(focusSpy).toHaveBeenCalled(); - }); - describe('combobox could customize input element', () => { it('work', () => { const onKeyDown = jest.fn(); @@ -1432,17 +1417,55 @@ describe('Select.Basic', () => { expect(onKeyUp).toHaveBeenCalled(); }); - it('warning if label not same as option', () => { - const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); - mount( - , - ); - expect(errorSpy).toHaveBeenCalledWith( - 'Warning: `label` of `value` is not same as `label` in Select options.', - ); - errorSpy.mockRestore(); + describe('warning if label not same as option', () => { + it('should work', () => { + resetWarned(); + + const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + mount( + , + ); + expect(errorSpy).toHaveBeenCalledWith( + 'Warning: `label` of `value` is not same as `label` in Select options.', + ); + errorSpy.mockRestore(); + }); + + it('not warning for react node', () => { + resetWarned(); + const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + + const Demo = () => { + const [, setVal] = React.useState(0); + + return ( + ); - expect( - wrapper.find('.rc-select-selection-placeholder').getDOMNode().hasAttribute('style'), - ).toBe(false); - toggleOpen(wrapper); - expect( - (wrapper.find('.rc-select-selection-placeholder').getDOMNode() as HTMLSpanElement).style - .visibility, - ).toBe('hidden'); - }); - - it('when value is null', () => { - const wrapper = mount(, - ); - expect(wrapper.find('.rc-select-selection-placeholder').length).toBeFalsy(); - }); - }); - it('Remove options can keep the cache', () => { const wrapper = mount(, - ); - expect( - (wrapper.find('.rc-select-selection-placeholder').getDOMNode() as HTMLSpanElement).style - .visibility, - ).toBe('hidden'); - }); - it('no warning for non-dom attr', () => { const wrapper = mount( ); + expect( + wrapper.find('.rc-select-selection-placeholder').getDOMNode().hasAttribute('style'), + ).toBe(false); + toggleOpen(wrapper); + expect( + (wrapper.find('.rc-select-selection-placeholder').getDOMNode() as HTMLSpanElement).style + .visibility, + ).toBe('hidden'); + }); + + it('when value is null', () => { + const wrapper = mount(, + ); + expect(wrapper.find('.rc-select-selection-placeholder').length).toBe(0); + expect(wrapper.find('.rc-select-selection-item').text()).toBe('light'); + toggleOpen(wrapper); + expect(wrapper.find('.rc-select-selection-item').text()).toBe('light'); + }); + + it('should hide placeholder if force closed and showSearch with searchValue', () => { + const wrapper = mount( +