Skip to content

Commit 710d513

Browse files
authored
Remove ReactTestUtils from ReactIdentity (#28332)
1 parent 2e470a7 commit 710d513

File tree

1 file changed

+32
-18
lines changed

1 file changed

+32
-18
lines changed

packages/react-dom/src/__tests__/ReactIdentity-test.js

+32-18
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@
1111

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

1716
describe('ReactIdentity', () => {
1817
beforeEach(() => {
1918
jest.resetModules();
2019
React = require('react');
2120
ReactDOMClient = require('react-dom/client');
22-
ReactTestUtils = require('react-dom/test-utils');
2321
act = require('internal-test-utils').act;
2422
});
2523

@@ -127,7 +125,7 @@ describe('ReactIdentity', () => {
127125
expect(window.YOUVEBEENH4X0RED).toBe(undefined);
128126
});
129127

130-
it('should let restructured components retain their uniqueness', () => {
128+
it('should let restructured components retain their uniqueness', async () => {
131129
const instance0 = <span />;
132130
const instance1 = <span />;
133131
const instance2 = <span />;
@@ -155,12 +153,16 @@ describe('ReactIdentity', () => {
155153
}
156154
}
157155

158-
expect(function () {
159-
ReactTestUtils.renderIntoDocument(<TestContainer />);
160-
}).not.toThrow();
156+
const container = document.createElement('div');
157+
const root = ReactDOMClient.createRoot(container);
158+
await expect(
159+
act(() => {
160+
root.render(<TestContainer />);
161+
}),
162+
).resolves.not.toThrow();
161163
});
162164

163-
it('should let nested restructures retain their uniqueness', () => {
165+
it('should let nested restructures retain their uniqueness', async () => {
164166
const instance0 = <span />;
165167
const instance1 = <span />;
166168
const instance2 = <span />;
@@ -190,12 +192,16 @@ describe('ReactIdentity', () => {
190192
}
191193
}
192194

193-
expect(function () {
194-
ReactTestUtils.renderIntoDocument(<TestContainer />);
195-
}).not.toThrow();
195+
const container = document.createElement('div');
196+
const root = ReactDOMClient.createRoot(container);
197+
await expect(
198+
act(() => {
199+
root.render(<TestContainer />);
200+
}),
201+
).resolves.not.toThrow();
196202
});
197203

198-
it('should let text nodes retain their uniqueness', () => {
204+
it('should let text nodes retain their uniqueness', async () => {
199205
class TestComponent extends React.Component {
200206
render() {
201207
return (
@@ -218,9 +224,13 @@ describe('ReactIdentity', () => {
218224
}
219225
}
220226

221-
expect(function () {
222-
ReactTestUtils.renderIntoDocument(<TestContainer />);
223-
}).not.toThrow();
227+
const container = document.createElement('div');
228+
const root = ReactDOMClient.createRoot(container);
229+
await expect(
230+
act(() => {
231+
root.render(<TestContainer />);
232+
}),
233+
).resolves.not.toThrow();
224234
});
225235

226236
it('should retain key during updates in composite components', async () => {
@@ -272,17 +282,21 @@ describe('ReactIdentity', () => {
272282
expect(beforeB).toBe(afterB);
273283
});
274284

275-
it('should not allow implicit and explicit keys to collide', () => {
285+
it('should not allow implicit and explicit keys to collide', async () => {
276286
const component = (
277287
<div>
278288
<span />
279289
<span key="0" />
280290
</div>
281291
);
282292

283-
expect(function () {
284-
ReactTestUtils.renderIntoDocument(component);
285-
}).not.toThrow();
293+
const container = document.createElement('div');
294+
const root = ReactDOMClient.createRoot(container);
295+
await expect(
296+
act(() => {
297+
root.render(component);
298+
}),
299+
).resolves.not.toThrow();
286300
});
287301

288302
it('should throw if key is a Temporal-like object', async () => {

0 commit comments

Comments
 (0)