Skip to content

Commit f1ab7e6

Browse files
author
Sebastian Silbermann
committed
Remove ReactTestUtils from ReactJSXTransformIntegration
1 parent adadb81 commit f1ab7e6

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

packages/react/src/__tests__/ReactJSXTransformIntegration-test.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
let React;
1313
let ReactDOMClient;
14-
let ReactTestUtils;
1514
let act;
1615

1716
// TODO: Historically this module was used to confirm that the JSX transform
@@ -30,7 +29,6 @@ describe('ReactJSXTransformIntegration', () => {
3029

3130
React = require('react');
3231
ReactDOMClient = require('react-dom/client');
33-
ReactTestUtils = require('react-dom/test-utils');
3432
act = require('internal-test-utils').act;
3533

3634
Component = class extends React.Component {
@@ -213,22 +211,34 @@ describe('ReactJSXTransformIntegration', () => {
213211
expect(instance.props.fruit).toBe('persimmon');
214212
});
215213

216-
it('should normalize props with default values', () => {
214+
it('should normalize props with default values', async () => {
217215
class NormalizingComponent extends React.Component {
218216
render() {
219217
return <span>{this.props.prop}</span>;
220218
}
221219
}
222220
NormalizingComponent.defaultProps = {prop: 'testKey'};
223221

224-
const instance = ReactTestUtils.renderIntoDocument(
225-
<NormalizingComponent />,
226-
);
222+
let container = document.createElement('div');
223+
let root = ReactDOMClient.createRoot(container);
224+
let instance;
225+
await act(() => {
226+
root.render(
227+
<NormalizingComponent ref={current => (instance = current)} />,
228+
);
229+
});
230+
227231
expect(instance.props.prop).toBe('testKey');
228232

229-
const inst2 = ReactTestUtils.renderIntoDocument(
230-
<NormalizingComponent prop={null} />,
231-
);
233+
container = document.createElement('div');
234+
root = ReactDOMClient.createRoot(container);
235+
let inst2;
236+
await act(() => {
237+
root.render(
238+
<NormalizingComponent prop={null} ref={current => (inst2 = current)} />,
239+
);
240+
});
241+
232242
expect(inst2.props.prop).toBe(null);
233243
});
234244
});

0 commit comments

Comments
 (0)