Skip to content

Commit 53fef45

Browse files
committed
test: add Select case
1 parent c4fd947 commit 53fef45

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/Select.test.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,4 +2367,28 @@ describe('Select.Basic', () => {
23672367
expect(element[0]).not.toHaveClass('rc-select-item-option-disabled');
23682368
expect(element[1]).toHaveClass('rc-select-item-option-disabled');
23692369
});
2370+
2371+
it('click item and blur should trigger onBlur but not trigger onSearch', () => {
2372+
const onSearch = jest.fn();
2373+
const onBlur = jest.fn();
2374+
2375+
const Demo = () => (
2376+
<Select onSearch={onSearch} showSearch onBlur={onBlur}>
2377+
<Option value="11">11</Option>
2378+
<Option value="22">22</Option>
2379+
<Option value="33">33</Option>
2380+
</Select>
2381+
);
2382+
2383+
const { container } = render(<Demo />);
2384+
const input = container.querySelector('input');
2385+
fireEvent.change(input, { target: { value: '1' } });
2386+
fireEvent.click(
2387+
container.querySelectorAll('.rc-select-dropdown .rc-select-item-option-content')[0],
2388+
);
2389+
fireEvent.blur(input);
2390+
expect(container.querySelector('.rc-select-dropdown-hidden')).toBeTruthy();
2391+
expect(onSearch).toHaveBeenCalledTimes(1);
2392+
expect(onBlur).toHaveBeenCalledTimes(1);
2393+
});
23702394
});

0 commit comments

Comments
 (0)