Skip to content

Commit

Permalink
test: add Select case
Browse files Browse the repository at this point in the history
  • Loading branch information
su-muzhi committed Nov 14, 2024
1 parent c4fd947 commit 53fef45
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2367,4 +2367,28 @@ describe('Select.Basic', () => {
expect(element[0]).not.toHaveClass('rc-select-item-option-disabled');
expect(element[1]).toHaveClass('rc-select-item-option-disabled');
});

it('click item and blur should trigger onBlur but not trigger onSearch', () => {
const onSearch = jest.fn();
const onBlur = jest.fn();

const Demo = () => (
<Select onSearch={onSearch} showSearch onBlur={onBlur}>
<Option value="11">11</Option>
<Option value="22">22</Option>
<Option value="33">33</Option>
</Select>
);

const { container } = render(<Demo />);
const input = container.querySelector('input');
fireEvent.change(input, { target: { value: '1' } });
fireEvent.click(
container.querySelectorAll('.rc-select-dropdown .rc-select-item-option-content')[0],
);
fireEvent.blur(input);
expect(container.querySelector('.rc-select-dropdown-hidden')).toBeTruthy();
expect(onSearch).toHaveBeenCalledTimes(1);
expect(onBlur).toHaveBeenCalledTimes(1);
});
});

0 comments on commit 53fef45

Please sign in to comment.