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

Function dynamicChildrenTest

tests/shared/dynamicChildrenTest.tsx:7–184  ·  view source on GitHub ↗
(mode: any, props?: Partial<SelectProps>)

Source from the content-addressed store, hash-verified

5import { render } from '@testing-library/react';
6
7export default function dynamicChildrenTest(mode: any, props?: Partial<SelectProps>) {
8 injectRunAllTimers(jest);
9
10 beforeEach(() => {
11 jest.useFakeTimers();
12 });
13
14 afterEach(() => {
15 jest.useRealTimers();
16 });
17
18 it('dynamic children', () => {
19 const onChange = jest.fn();
20 const onSelect = jest.fn();
21
22 class App extends React.Component {
23 public state = {
24 value: ['1'],
25 options: [
26 <Option key="1" testprop="test">
27 1-label
28 </Option>,
29 <Option key="2">2-label</Option>,
30 ],
31 };
32
33 public select: any;
34
35 public componentDidMount() {
36 setTimeout(() => {
37 this.updateChildren();
38 }, 10);
39 }
40
41 public updateChildren = () => {
42 this.setState({
43 options: [<Option key="2">2-label</Option>, <Option key="3">3-label</Option>],
44 });
45 };
46
47 public render() {
48 return (
49 <Select
50 value={this.state.value}
51 ref={(node) => {
52 this.select = node;
53 }}
54 mode={mode}
55 {...props}
56 onChange={onChange}
57 onSelect={onSelect}
58 >
59 {this.state.options}
60 </Select>
61 );
62 }
63 }
64

Callers 2

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

Calls 4

injectRunAllTimersFunction · 0.90
toggleOpenFunction · 0.90
selectItemFunction · 0.90
findSelectionFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…