11
11
12
12
let React ;
13
13
let ReactDOMClient ;
14
- let ReactTestUtils ;
15
14
let act ;
16
15
17
16
describe ( 'ReactIdentity' , ( ) => {
18
17
beforeEach ( ( ) => {
19
18
jest . resetModules ( ) ;
20
19
React = require ( 'react' ) ;
21
20
ReactDOMClient = require ( 'react-dom/client' ) ;
22
- ReactTestUtils = require ( 'react-dom/test-utils' ) ;
23
21
act = require ( 'internal-test-utils' ) . act ;
24
22
} ) ;
25
23
@@ -127,7 +125,7 @@ describe('ReactIdentity', () => {
127
125
expect ( window . YOUVEBEENH4X0RED ) . toBe ( undefined ) ;
128
126
} ) ;
129
127
130
- it ( 'should let restructured components retain their uniqueness' , ( ) => {
128
+ it ( 'should let restructured components retain their uniqueness' , async ( ) => {
131
129
const instance0 = < span /> ;
132
130
const instance1 = < span /> ;
133
131
const instance2 = < span /> ;
@@ -155,12 +153,16 @@ describe('ReactIdentity', () => {
155
153
}
156
154
}
157
155
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 ( ) ;
161
163
} ) ;
162
164
163
- it ( 'should let nested restructures retain their uniqueness' , ( ) => {
165
+ it ( 'should let nested restructures retain their uniqueness' , async ( ) => {
164
166
const instance0 = < span /> ;
165
167
const instance1 = < span /> ;
166
168
const instance2 = < span /> ;
@@ -190,12 +192,16 @@ describe('ReactIdentity', () => {
190
192
}
191
193
}
192
194
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 ( ) ;
196
202
} ) ;
197
203
198
- it ( 'should let text nodes retain their uniqueness' , ( ) => {
204
+ it ( 'should let text nodes retain their uniqueness' , async ( ) => {
199
205
class TestComponent extends React . Component {
200
206
render ( ) {
201
207
return (
@@ -218,9 +224,13 @@ describe('ReactIdentity', () => {
218
224
}
219
225
}
220
226
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 ( ) ;
224
234
} ) ;
225
235
226
236
it ( 'should retain key during updates in composite components' , async ( ) => {
@@ -272,17 +282,21 @@ describe('ReactIdentity', () => {
272
282
expect ( beforeB ) . toBe ( afterB ) ;
273
283
} ) ;
274
284
275
- it ( 'should not allow implicit and explicit keys to collide' , ( ) => {
285
+ it ( 'should not allow implicit and explicit keys to collide' , async ( ) => {
276
286
const component = (
277
287
< div >
278
288
< span />
279
289
< span key = "0" />
280
290
</ div >
281
291
) ;
282
292
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 ( ) ;
286
300
} ) ;
287
301
288
302
it ( 'should throw if key is a Temporal-like object' , async ( ) => {
0 commit comments