7
7
* @flow
8
8
*/
9
9
10
- import { normalizeCodeLocInfo } from './utils' ;
10
+ import { getVersionedRenderImplementation , normalizeCodeLocInfo } from './utils' ;
11
11
12
12
let React ;
13
13
let ReactDOMClient ;
14
14
let act ;
15
15
let fakeConsole ;
16
- let legacyRender ;
17
16
let mockError ;
18
17
let mockInfo ;
19
18
let mockGroup ;
@@ -67,9 +66,10 @@ describe('console', () => {
67
66
68
67
const utils = require ( './utils' ) ;
69
68
act = utils . act ;
70
- legacyRender = utils . legacyRender ;
71
69
} ) ;
72
70
71
+ const { render} = getVersionedRenderImplementation ( ) ;
72
+
73
73
// @reactVersion >=18.0
74
74
it ( 'should not patch console methods that are not explicitly overridden' , ( ) => {
75
75
expect ( fakeConsole . error ) . not . toBe ( mockError ) ;
@@ -185,7 +185,7 @@ describe('console', () => {
185
185
return null ;
186
186
} ;
187
187
188
- act ( ( ) => legacyRender ( < Child /> , document . createElement ( 'div' ) ) ) ;
188
+ act ( ( ) => render ( < Child /> ) ) ;
189
189
190
190
expect ( mockWarn ) . toHaveBeenCalledTimes ( 1 ) ;
191
191
expect ( mockWarn . mock . calls [ 0 ] ) . toHaveLength ( 1 ) ;
@@ -215,7 +215,7 @@ describe('console', () => {
215
215
return null ;
216
216
} ;
217
217
218
- act ( ( ) => legacyRender ( < Parent /> , document . createElement ( 'div' ) ) ) ;
218
+ act ( ( ) => render ( < Parent /> ) ) ;
219
219
220
220
expect ( mockLog ) . toHaveBeenCalledTimes ( 1 ) ;
221
221
expect ( mockLog . mock . calls [ 0 ] ) . toHaveLength ( 1 ) ;
@@ -256,7 +256,7 @@ describe('console', () => {
256
256
return null ;
257
257
} ;
258
258
259
- act ( ( ) => legacyRender ( < Parent /> , document . createElement ( 'div' ) ) ) ;
259
+ act ( ( ) => render ( < Parent /> ) ) ;
260
260
261
261
expect ( mockLog ) . toHaveBeenCalledTimes ( 2 ) ;
262
262
expect ( mockLog . mock . calls [ 0 ] ) . toHaveLength ( 1 ) ;
@@ -313,9 +313,8 @@ describe('console', () => {
313
313
}
314
314
}
315
315
316
- const container = document . createElement ( 'div' ) ;
317
- act ( ( ) => legacyRender ( < Parent /> , container ) ) ;
318
- act ( ( ) => legacyRender ( < Parent /> , container ) ) ;
316
+ act ( ( ) => render ( < Parent /> ) ) ;
317
+ act ( ( ) => render ( < Parent /> ) ) ;
319
318
320
319
expect ( mockLog ) . toHaveBeenCalledTimes ( 2 ) ;
321
320
expect ( mockLog . mock . calls [ 0 ] ) . toHaveLength ( 1 ) ;
@@ -367,7 +366,7 @@ describe('console', () => {
367
366
}
368
367
}
369
368
370
- act ( ( ) => legacyRender ( < Parent /> , document . createElement ( 'div' ) ) ) ;
369
+ act ( ( ) => render ( < Parent /> ) ) ;
371
370
372
371
expect ( mockLog ) . toHaveBeenCalledTimes ( 1 ) ;
373
372
expect ( mockLog . mock . calls [ 0 ] ) . toHaveLength ( 1 ) ;
@@ -396,7 +395,7 @@ describe('console', () => {
396
395
return null ;
397
396
} ;
398
397
399
- act ( ( ) => legacyRender ( < Child /> , document . createElement ( 'div' ) ) ) ;
398
+ act ( ( ) => render ( < Child /> ) ) ;
400
399
401
400
expect ( mockWarn ) . toHaveBeenCalledTimes ( 1 ) ;
402
401
expect ( mockWarn . mock . calls [ 0 ] ) . toHaveLength ( 1 ) ;
@@ -410,7 +409,7 @@ describe('console', () => {
410
409
breakOnConsoleErrors : false ,
411
410
showInlineWarningsAndErrors : false ,
412
411
} ) ;
413
- act ( ( ) => legacyRender ( < Child /> , document . createElement ( 'div' ) ) ) ;
412
+ act ( ( ) => render ( < Child /> ) ) ;
414
413
415
414
expect ( mockWarn ) . toHaveBeenCalledTimes ( 2 ) ;
416
415
expect ( mockWarn . mock . calls [ 1 ] ) . toHaveLength ( 2 ) ;
@@ -457,7 +456,7 @@ describe('console', () => {
457
456
return null ;
458
457
} ;
459
458
460
- act ( ( ) => legacyRender ( < Parent /> , document . createElement ( 'div' ) ) ) ;
459
+ act ( ( ) => render ( < Parent /> ) ) ;
461
460
462
461
expect ( mockLog ) . toHaveBeenCalledTimes ( 1 ) ;
463
462
expect ( mockLog . mock . calls [ 0 ] ) . toHaveLength ( 1 ) ;
@@ -483,7 +482,7 @@ describe('console', () => {
483
482
return null ;
484
483
} ;
485
484
486
- act ( ( ) => legacyRender ( < Component /> , document . createElement ( 'div' ) ) ) ;
485
+ act ( ( ) => render ( < Component /> ) ) ;
487
486
488
487
expect ( mockWarn ) . toHaveBeenCalledTimes ( 1 ) ;
489
488
expect ( mockWarn . mock . calls [ 0 ] [ 0 ] ) . toBe ( 'Symbol:' ) ;
@@ -824,7 +823,6 @@ describe('console error', () => {
824
823
825
824
const utils = require ( './utils' ) ;
826
825
act = utils . act ;
827
- legacyRender = utils . legacyRender ;
828
826
} ) ;
829
827
830
828
// @reactVersion >=18.0
0 commit comments