MCPcopy Create free account
hub / github.com/react-component/select / maxTagTextLengthTest

Function maxTagTextLengthTest

tests/shared/maxTagRenderTest.tsx:7–130  ·  view source on GitHub ↗
(mode: any)

Source from the content-addressed store, hash-verified

5import { render } from '@testing-library/react';
6
7export default function maxTagTextLengthTest(mode: any) {
8 describe('max tag render', () => {
9 it('truncates values by maxTagTextLength', () => {
10 const { container } = render(
11 <Select mode={mode} value={['one', 'two']} maxTagTextLength={2}>
12 <Option value="one">One</Option>
13 <Option value="two">Two</Option>
14 </Select>,
15 );
16
17 expect(container.firstChild).toMatchSnapshot();
18 });
19
20 it('truncates tags by maxTagCount', () => {
21 const { container } = render(
22 <Select mode={mode} value={['one', 'two', 'three']} maxTagCount={2}>
23 <Option value="one">One</Option>
24 <Option value="two">Two</Option>
25 <Option value="three">Three</Option>
26 </Select>,
27 );
28
29 expect(container.querySelectorAll('.rc-select-selection-item')).toHaveLength(3);
30 });
31
32 it('truncates tags by maxTagCount while maxTagCount is 0', () => {
33 const { container } = render(
34 <Select mode={mode} value={['one', 'two', 'three']} maxTagCount={0}>
35 <Option value="one">One</Option>
36 <Option value="two">Two</Option>
37 <Option value="three">Three</Option>
38 </Select>,
39 );
40
41 expect(container.querySelectorAll('.rc-select-selection-item')).toHaveLength(1);
42 expect(findSelection(container).textContent).toEqual('+ 3 ...');
43 });
44
45 it('not display maxTagPlaceholder if maxTagCount not reach', () => {
46 const { container } = render(
47 <Select mode={mode} maxTagCount={2}>
48 <Option value="one">One</Option>
49 <Option value="two">Two</Option>
50 <Option value="three">Three</Option>
51 </Select>,
52 );
53
54 expect(container.firstChild).toMatchSnapshot();
55 });
56
57 it('truncates tags by maxTagCount and show maxTagPlaceholder', () => {
58 const { container } = render(
59 <Select
60 mode={mode}
61 value={['one', 'two', 'three']}
62 maxTagCount={2}
63 maxTagPlaceholder={<span>Omitted</span>}
64 >

Callers

nothing calls this directly

Calls 1

findSelectionFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…