()
| 46 | let hostComponentID; |
| 47 | |
| 48 | async function mountTestApp() { |
| 49 | class ClassComponent extends React.Component { |
| 50 | componentDidMount() { |
| 51 | committedClassProps = this.props; |
| 52 | } |
| 53 | componentDidUpdate() { |
| 54 | committedClassProps = this.props; |
| 55 | } |
| 56 | render() { |
| 57 | return null; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | function FunctionComponent(props) { |
| 62 | React.useLayoutEffect(() => { |
| 63 | committedFunctionProps = props; |
| 64 | }); |
| 65 | return null; |
| 66 | } |
| 67 | |
| 68 | inputRef = React.createRef(null); |
| 69 | |
| 70 | await utils.actAsync(() => |
| 71 | render( |
| 72 | <> |
| 73 | <ClassComponent |
| 74 | array={[1, 2, 3]} |
| 75 | object={{nested: 'initial'}} |
| 76 | shallow="initial" |
| 77 | /> |
| 78 | , |
| 79 | <FunctionComponent |
| 80 | array={[1, 2, 3]} |
| 81 | object={{nested: 'initial'}} |
| 82 | shallow="initial" |
| 83 | /> |
| 84 | , |
| 85 | <input ref={inputRef} onChange={jest.fn()} value="initial" /> |
| 86 | </>, |
| 87 | ), |
| 88 | ); |
| 89 | |
| 90 | classID = ((store.getElementIDAtIndex(0): any): number); |
| 91 | functionID = ((store.getElementIDAtIndex(1): any): number); |
| 92 | hostComponentID = ((store.getElementIDAtIndex(2): any): number); |
| 93 | |
| 94 | expect(committedClassProps).toStrictEqual({ |
| 95 | array: [1, 2, 3], |
| 96 | object: { |
| 97 | nested: 'initial', |
| 98 | }, |
| 99 | shallow: 'initial', |
| 100 | }); |
| 101 | expect(committedFunctionProps).toStrictEqual({ |
| 102 | array: [1, 2, 3], |
| 103 | object: { |
| 104 | nested: 'initial', |
| 105 | }, |
no test coverage detected