Skip to content

Commit 960f65a

Browse files
author
刘欢
committed
test: test showsearch and mode
1 parent 360bfd5 commit 960f65a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/Select.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,5 +2653,22 @@ describe('Select.Basic', () => {
26532653
expect(legacyInput).toHaveValue('a');
26542654
expect(currentInput).toHaveValue('a');
26552655
});
2656+
2657+
it.only.each([
2658+
// [description, props, shouldExist]
2659+
['showSearch=false and mode=undefined', { showSearch: false }, false],
2660+
['showSearch=undefined and mode=undefined', {}, false],
2661+
['showSearch=undefined and mode=tags', { mode: 'tags' }, true],
2662+
['showSearch=false and mode=tags', { showSearch: false, mode: 'tags' }, true],
2663+
['showSearch=true and mode=undefined', { showSearch: true }, true],
2664+
])('%s', (_, props: { showSearch?: boolean; mode?: 'tags' }, shouldExist) => {
2665+
const { container } = render(<Select options={[{ value: 'a', label: '1' }]} {...props} />);
2666+
const inputNode = container.querySelector('input');
2667+
if (shouldExist) {
2668+
expect(inputNode).not.toHaveAttribute('readonly');
2669+
} else {
2670+
expect(inputNode).toHaveAttribute('readonly');
2671+
}
2672+
});
26562673
});
26572674
});

0 commit comments

Comments
 (0)