MCPcopy Index your code
hub / github.com/react-component/select / inputFilterTest

Function inputFilterTest

tests/shared/inputFilterTest.tsx:6–48  ·  view source on GitHub ↗
(mode: any)

Source from the content-addressed store, hash-verified

4import { fireEvent, render } from '@testing-library/react';
5
6export default function inputFilterTest(mode: any) {
7 it('should keep input filter after select when autoClearSearchValue is false', () => {
8 const { container } = render(
9 <Select mode={mode} autoClearSearchValue={false} showSearch>
10 <Option value="11">11</Option>
11 <Option value="12">12</Option>
12 <Option value="22">22</Option>
13 </Select>,
14 );
15 const input = container.querySelector('input');
16 fireEvent.change(input, {
17 target: {
18 value: '1',
19 },
20 });
21
22 expect(container.querySelector('.rc-select')).toHaveClass('rc-select-open');
23 expect(container.querySelector('input')).toHaveValue('1');
24 fireEvent.click(container.querySelector('.rc-select-item-option'));
25 expect(container.querySelector('input')).toHaveValue(mode === 'single' ? '' : '1');
26 });
27
28 it('should clear input filter after select', () => {
29 const { container } = render(
30 <Select mode={mode} showSearch>
31 <Option value="11">11</Option>
32 <Option value="12">12</Option>
33 <Option value="22">22</Option>
34 </Select>,
35 );
36 const input = container.querySelector('input');
37 fireEvent.change(input, {
38 target: {
39 value: '1',
40 },
41 });
42
43 expect(container.querySelector('.rc-select')).toHaveClass('rc-select-open');
44 expect(container.querySelector('input')).toHaveValue('1');
45 fireEvent.click(container.querySelector('.rc-select-item-option'));
46 expect(container.querySelector('input')).toHaveValue('');
47 });
48}

Callers 3

Select.test.tsxFile · 0.85
Tags.test.tsxFile · 0.85
Multiple.test.tsxFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…