11
11
12
12
let React ;
13
13
let ReactDOM ;
14
- let ReactTestUtils ;
15
14
let act ;
16
15
let Scheduler ;
17
16
let assertLog ;
@@ -23,7 +22,6 @@ describe('ReactLegacyUpdates', () => {
23
22
jest . resetModules ( ) ;
24
23
React = require ( 'react' ) ;
25
24
ReactDOM = require ( 'react-dom' ) ;
26
- ReactTestUtils = require ( 'react-dom/test-utils' ) ;
27
25
act = require ( 'internal-test-utils' ) . act ;
28
26
Scheduler = require ( 'scheduler' ) ;
29
27
@@ -47,7 +45,8 @@ describe('ReactLegacyUpdates', () => {
47
45
}
48
46
}
49
47
50
- const instance = ReactTestUtils . renderIntoDocument ( < Component /> ) ;
48
+ const container = document . createElement ( 'div' ) ;
49
+ const instance = ReactDOM . render ( < Component /> , container ) ;
51
50
expect ( instance . state . x ) . toBe ( 0 ) ;
52
51
53
52
ReactDOM . unstable_batchedUpdates ( function ( ) {
@@ -77,7 +76,8 @@ describe('ReactLegacyUpdates', () => {
77
76
}
78
77
}
79
78
80
- const instance = ReactTestUtils . renderIntoDocument ( < Component /> ) ;
79
+ const container = document . createElement ( 'div' ) ;
80
+ const instance = ReactDOM . render ( < Component /> , container ) ;
81
81
expect ( instance . state . x ) . toBe ( 0 ) ;
82
82
expect ( instance . state . y ) . toBe ( 0 ) ;
83
83
@@ -163,7 +163,8 @@ describe('ReactLegacyUpdates', () => {
163
163
}
164
164
}
165
165
166
- const instance = ReactTestUtils . renderIntoDocument ( < Parent /> ) ;
166
+ const container = document . createElement ( 'div' ) ;
167
+ const instance = ReactDOM . render ( < Parent /> , container ) ;
167
168
const child = instance . childRef . current ;
168
169
expect ( instance . state . x ) . toBe ( 0 ) ;
169
170
expect ( child . state . y ) . toBe ( 0 ) ;
@@ -218,7 +219,8 @@ describe('ReactLegacyUpdates', () => {
218
219
}
219
220
}
220
221
221
- const instance = ReactTestUtils . renderIntoDocument ( < Parent /> ) ;
222
+ const container = document . createElement ( 'div' ) ;
223
+ const instance = ReactDOM . render ( < Parent /> , container ) ;
222
224
const child = instance . childRef . current ;
223
225
expect ( instance . state . x ) . toBe ( 0 ) ;
224
226
expect ( child . state . y ) . toBe ( 0 ) ;
@@ -256,7 +258,8 @@ describe('ReactLegacyUpdates', () => {
256
258
}
257
259
}
258
260
259
- const instance = ReactTestUtils . renderIntoDocument ( < Component /> ) ;
261
+ const container = document . createElement ( 'div' ) ;
262
+ const instance = ReactDOM . render ( < Component /> , container ) ;
260
263
expect ( instance . state . x ) . toBe ( 0 ) ;
261
264
262
265
let innerCallbackRun = false ;
@@ -301,7 +304,8 @@ describe('ReactLegacyUpdates', () => {
301
304
}
302
305
}
303
306
304
- const instance = ReactTestUtils . renderIntoDocument ( < Component /> ) ;
307
+ const container = document . createElement ( 'div' ) ;
308
+ const instance = ReactDOM . render ( < Component /> , container ) ;
305
309
expect ( instance . state . x ) . toBe ( 0 ) ;
306
310
307
311
let callbacksRun = 0 ;
@@ -351,8 +355,8 @@ describe('ReactLegacyUpdates', () => {
351
355
expect ( parentRenderCount ) . toBe ( 0 ) ;
352
356
expect ( childRenderCount ) . toBe ( 0 ) ;
353
357
354
- let instance = < Parent /> ;
355
- instance = ReactTestUtils . renderIntoDocument ( instance ) ;
358
+ const container = document . createElement ( 'div' ) ;
359
+ const instance = ReactDOM . render ( < Parent /> , container ) ;
356
360
357
361
expect ( parentRenderCount ) . toBe ( 1 ) ;
358
362
expect ( childRenderCount ) . toBe ( 1 ) ;
@@ -405,7 +409,8 @@ describe('ReactLegacyUpdates', () => {
405
409
}
406
410
}
407
411
408
- ReactTestUtils . renderIntoDocument ( < Top /> ) ;
412
+ const container = document . createElement ( 'div' ) ;
413
+ ReactDOM . render ( < Top /> , container ) ;
409
414
expect ( numMiddleRenders ) . toBe ( 2 ) ;
410
415
expect ( numBottomRenders ) . toBe ( 1 ) ;
411
416
} ) ;
@@ -478,8 +483,8 @@ describe('ReactLegacyUpdates', () => {
478
483
}
479
484
Object . assign ( App . prototype , UpdateLoggingMixin ) ;
480
485
481
- let root = < App /> ;
482
- root = ReactTestUtils . renderIntoDocument ( root ) ;
486
+ const container = document . createElement ( 'div' ) ;
487
+ const root = ReactDOM . render ( < App /> , container ) ;
483
488
484
489
function expectUpdates ( desiredWillUpdates , desiredDidUpdates ) {
485
490
let i ;
@@ -581,7 +586,8 @@ describe('ReactLegacyUpdates', () => {
581
586
}
582
587
}
583
588
584
- const a = ReactTestUtils . renderIntoDocument ( < A /> ) ;
589
+ const container = document . createElement ( 'div' ) ;
590
+ const a = ReactDOM . render ( < A /> , container ) ;
585
591
ReactDOM . unstable_batchedUpdates ( function ( ) {
586
592
a . setState ( { x : 1 } ) ;
587
593
b . setState ( { x : 1 } ) ;
@@ -630,7 +636,8 @@ describe('ReactLegacyUpdates', () => {
630
636
}
631
637
}
632
638
633
- const instance = ReactTestUtils . renderIntoDocument ( < Outer /> ) ;
639
+ const container = document . createElement ( 'div' ) ;
640
+ const instance = ReactDOM . render ( < Outer /> , container ) ;
634
641
635
642
updates . push ( 'Outer-setState-1' ) ;
636
643
instance . setState ( { x : 1 } , function ( ) {
@@ -698,7 +705,8 @@ describe('ReactLegacyUpdates', () => {
698
705
}
699
706
}
700
707
701
- ReactTestUtils . renderIntoDocument ( < MockComponent depth = { 0 } count = { 2 } /> ) ;
708
+ const container = document . createElement ( 'div' ) ;
709
+ ReactDOM . render ( < MockComponent depth = { 0 } count = { 2 } /> , container ) ;
702
710
703
711
expect ( updates ) . toEqual ( [ 0 , 1 , 2 ] ) ;
704
712
@@ -758,8 +766,10 @@ describe('ReactLegacyUpdates', () => {
758
766
}
759
767
}
760
768
761
- const x = ReactTestUtils . renderIntoDocument ( < X /> ) ;
762
- const y = ReactTestUtils . renderIntoDocument ( < Y /> ) ;
769
+ let container = document . createElement ( 'div' ) ;
770
+ const x = ReactDOM . render ( < X /> , container ) ;
771
+ container = document . createElement ( 'div' ) ;
772
+ const y = ReactDOM . render ( < Y /> , container ) ;
763
773
expect ( ReactDOM . findDOMNode ( x ) . textContent ) . toBe ( '0' ) ;
764
774
765
775
y . forceUpdate ( ) ;
@@ -794,11 +804,14 @@ describe('ReactLegacyUpdates', () => {
794
804
}
795
805
796
806
ReactDOM . unstable_batchedUpdates ( function ( ) {
797
- ReactTestUtils . renderIntoDocument (
807
+ const container = document . createElement ( 'div' ) ;
808
+
809
+ ReactDOM . render (
798
810
< div >
799
811
< A />
800
812
< B />
801
813
</ div > ,
814
+ container ,
802
815
) ;
803
816
} ) ;
804
817
@@ -859,7 +872,8 @@ describe('ReactLegacyUpdates', () => {
859
872
}
860
873
}
861
874
862
- const component = ReactTestUtils . renderIntoDocument ( < A /> ) ;
875
+ const container = document . createElement ( 'div' ) ;
876
+ const component = ReactDOM . render ( < A /> , container ) ;
863
877
864
878
ReactDOM . unstable_batchedUpdates ( function ( ) {
865
879
// B will have scheduled an update but the batching should ensure that its
@@ -886,7 +900,8 @@ describe('ReactLegacyUpdates', () => {
886
900
}
887
901
}
888
902
889
- let component = ReactTestUtils . renderIntoDocument ( < A /> ) ;
903
+ let container = document . createElement ( 'div' ) ;
904
+ let component = ReactDOM . render ( < A /> , container ) ;
890
905
891
906
expect ( ( ) => {
892
907
expect ( ( ) => component . setState ( { } , 'no' ) ) . toErrorDev (
@@ -897,7 +912,8 @@ describe('ReactLegacyUpdates', () => {
897
912
'Invalid argument passed as callback. Expected a function. Instead ' +
898
913
'received: no' ,
899
914
) ;
900
- component = ReactTestUtils . renderIntoDocument ( < A /> ) ;
915
+ container = document . createElement ( 'div' ) ;
916
+ component = ReactDOM . render ( < A /> , container ) ;
901
917
expect ( ( ) => {
902
918
expect ( ( ) => component . setState ( { } , { foo : 'bar' } ) ) . toErrorDev (
903
919
'Expected the last optional `callback` argument to be ' +
@@ -908,7 +924,8 @@ describe('ReactLegacyUpdates', () => {
908
924
'received: [object Object]' ,
909
925
) ;
910
926
// Make sure the warning is deduplicated and doesn't fire again
911
- component = ReactTestUtils . renderIntoDocument ( < A /> ) ;
927
+ container = document . createElement ( 'div' ) ;
928
+ component = ReactDOM . render ( < A /> , container ) ;
912
929
expect ( ( ) => component . setState ( { } , new Foo ( ) ) ) . toThrowError (
913
930
'Invalid argument passed as callback. Expected a function. Instead ' +
914
931
'received: [object Object]' ,
@@ -930,7 +947,8 @@ describe('ReactLegacyUpdates', () => {
930
947
}
931
948
}
932
949
933
- let component = ReactTestUtils . renderIntoDocument ( < A /> ) ;
950
+ let container = document . createElement ( 'div' ) ;
951
+ let component = ReactDOM . render ( < A /> , container ) ;
934
952
935
953
expect ( ( ) => {
936
954
expect ( ( ) => component . forceUpdate ( 'no' ) ) . toErrorDev (
@@ -941,7 +959,8 @@ describe('ReactLegacyUpdates', () => {
941
959
'Invalid argument passed as callback. Expected a function. Instead ' +
942
960
'received: no' ,
943
961
) ;
944
- component = ReactTestUtils . renderIntoDocument ( < A /> ) ;
962
+ container = document . createElement ( 'div' ) ;
963
+ component = ReactDOM . render ( < A /> , container ) ;
945
964
expect ( ( ) => {
946
965
expect ( ( ) => component . forceUpdate ( { foo : 'bar' } ) ) . toErrorDev (
947
966
'Expected the last optional `callback` argument to be ' +
@@ -952,7 +971,8 @@ describe('ReactLegacyUpdates', () => {
952
971
'received: [object Object]' ,
953
972
) ;
954
973
// Make sure the warning is deduplicated and doesn't fire again
955
- component = ReactTestUtils . renderIntoDocument ( < A /> ) ;
974
+ container = document . createElement ( 'div' ) ;
975
+ component = ReactDOM . render ( < A /> , container ) ;
956
976
expect ( ( ) => component . forceUpdate ( new Foo ( ) ) ) . toThrowError (
957
977
'Invalid argument passed as callback. Expected a function. Instead ' +
958
978
'received: [object Object]' ,
@@ -1004,7 +1024,8 @@ describe('ReactLegacyUpdates', () => {
1004
1024
}
1005
1025
}
1006
1026
1007
- const parent = ReactTestUtils . renderIntoDocument ( < Parent /> ) ;
1027
+ const container = document . createElement ( 'div' ) ;
1028
+ const parent = ReactDOM . render ( < Parent /> , container ) ;
1008
1029
const child = parent . getChild ( ) ;
1009
1030
ReactDOM . unstable_batchedUpdates ( function ( ) {
1010
1031
parent . forceUpdate ( ) ;
0 commit comments