1111
1212let React ;
1313let ReactDOM ;
14- let ReactTestUtils ;
1514let act ;
1615let Scheduler ;
1716let assertLog ;
@@ -23,7 +22,6 @@ describe('ReactLegacyUpdates', () => {
2322 jest . resetModules ( ) ;
2423 React = require ( 'react' ) ;
2524 ReactDOM = require ( 'react-dom' ) ;
26- ReactTestUtils = require ( 'react-dom/test-utils' ) ;
2725 act = require ( 'internal-test-utils' ) . act ;
2826 Scheduler = require ( 'scheduler' ) ;
2927
@@ -47,7 +45,8 @@ describe('ReactLegacyUpdates', () => {
4745 }
4846 }
4947
50- const instance = ReactTestUtils . renderIntoDocument ( < Component /> ) ;
48+ const container = document . createElement ( 'div' ) ;
49+ const instance = ReactDOM . render ( < Component /> , container ) ;
5150 expect ( instance . state . x ) . toBe ( 0 ) ;
5251
5352 ReactDOM . unstable_batchedUpdates ( function ( ) {
@@ -77,7 +76,8 @@ describe('ReactLegacyUpdates', () => {
7776 }
7877 }
7978
80- const instance = ReactTestUtils . renderIntoDocument ( < Component /> ) ;
79+ const container = document . createElement ( 'div' ) ;
80+ const instance = ReactDOM . render ( < Component /> , container ) ;
8181 expect ( instance . state . x ) . toBe ( 0 ) ;
8282 expect ( instance . state . y ) . toBe ( 0 ) ;
8383
@@ -163,7 +163,8 @@ describe('ReactLegacyUpdates', () => {
163163 }
164164 }
165165
166- const instance = ReactTestUtils . renderIntoDocument ( < Parent /> ) ;
166+ const container = document . createElement ( 'div' ) ;
167+ const instance = ReactDOM . render ( < Parent /> , container ) ;
167168 const child = instance . childRef . current ;
168169 expect ( instance . state . x ) . toBe ( 0 ) ;
169170 expect ( child . state . y ) . toBe ( 0 ) ;
@@ -218,7 +219,8 @@ describe('ReactLegacyUpdates', () => {
218219 }
219220 }
220221
221- const instance = ReactTestUtils . renderIntoDocument ( < Parent /> ) ;
222+ const container = document . createElement ( 'div' ) ;
223+ const instance = ReactDOM . render ( < Parent /> , container ) ;
222224 const child = instance . childRef . current ;
223225 expect ( instance . state . x ) . toBe ( 0 ) ;
224226 expect ( child . state . y ) . toBe ( 0 ) ;
@@ -256,7 +258,8 @@ describe('ReactLegacyUpdates', () => {
256258 }
257259 }
258260
259- const instance = ReactTestUtils . renderIntoDocument ( < Component /> ) ;
261+ const container = document . createElement ( 'div' ) ;
262+ const instance = ReactDOM . render ( < Component /> , container ) ;
260263 expect ( instance . state . x ) . toBe ( 0 ) ;
261264
262265 let innerCallbackRun = false ;
@@ -301,7 +304,8 @@ describe('ReactLegacyUpdates', () => {
301304 }
302305 }
303306
304- const instance = ReactTestUtils . renderIntoDocument ( < Component /> ) ;
307+ const container = document . createElement ( 'div' ) ;
308+ const instance = ReactDOM . render ( < Component /> , container ) ;
305309 expect ( instance . state . x ) . toBe ( 0 ) ;
306310
307311 let callbacksRun = 0 ;
@@ -351,8 +355,8 @@ describe('ReactLegacyUpdates', () => {
351355 expect ( parentRenderCount ) . toBe ( 0 ) ;
352356 expect ( childRenderCount ) . toBe ( 0 ) ;
353357
354- let instance = < Parent /> ;
355- instance = ReactTestUtils . renderIntoDocument ( instance ) ;
358+ const container = document . createElement ( 'div' ) ;
359+ const instance = ReactDOM . render ( < Parent /> , container ) ;
356360
357361 expect ( parentRenderCount ) . toBe ( 1 ) ;
358362 expect ( childRenderCount ) . toBe ( 1 ) ;
@@ -405,7 +409,8 @@ describe('ReactLegacyUpdates', () => {
405409 }
406410 }
407411
408- ReactTestUtils . renderIntoDocument ( < Top /> ) ;
412+ const container = document . createElement ( 'div' ) ;
413+ ReactDOM . render ( < Top /> , container ) ;
409414 expect ( numMiddleRenders ) . toBe ( 2 ) ;
410415 expect ( numBottomRenders ) . toBe ( 1 ) ;
411416 } ) ;
@@ -478,8 +483,8 @@ describe('ReactLegacyUpdates', () => {
478483 }
479484 Object . assign ( App . prototype , UpdateLoggingMixin ) ;
480485
481- let root = < App /> ;
482- root = ReactTestUtils . renderIntoDocument ( root ) ;
486+ const container = document . createElement ( 'div' ) ;
487+ const root = ReactDOM . render ( < App /> , container ) ;
483488
484489 function expectUpdates ( desiredWillUpdates , desiredDidUpdates ) {
485490 let i ;
@@ -581,7 +586,8 @@ describe('ReactLegacyUpdates', () => {
581586 }
582587 }
583588
584- const a = ReactTestUtils . renderIntoDocument ( < A /> ) ;
589+ const container = document . createElement ( 'div' ) ;
590+ const a = ReactDOM . render ( < A /> , container ) ;
585591 ReactDOM . unstable_batchedUpdates ( function ( ) {
586592 a . setState ( { x : 1 } ) ;
587593 b . setState ( { x : 1 } ) ;
@@ -630,7 +636,8 @@ describe('ReactLegacyUpdates', () => {
630636 }
631637 }
632638
633- const instance = ReactTestUtils . renderIntoDocument ( < Outer /> ) ;
639+ const container = document . createElement ( 'div' ) ;
640+ const instance = ReactDOM . render ( < Outer /> , container ) ;
634641
635642 updates . push ( 'Outer-setState-1' ) ;
636643 instance . setState ( { x : 1 } , function ( ) {
@@ -698,7 +705,8 @@ describe('ReactLegacyUpdates', () => {
698705 }
699706 }
700707
701- ReactTestUtils . renderIntoDocument ( < MockComponent depth = { 0 } count = { 2 } /> ) ;
708+ const container = document . createElement ( 'div' ) ;
709+ ReactDOM . render ( < MockComponent depth = { 0 } count = { 2 } /> , container ) ;
702710
703711 expect ( updates ) . toEqual ( [ 0 , 1 , 2 ] ) ;
704712
@@ -758,8 +766,10 @@ describe('ReactLegacyUpdates', () => {
758766 }
759767 }
760768
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 ) ;
763773 expect ( ReactDOM . findDOMNode ( x ) . textContent ) . toBe ( '0' ) ;
764774
765775 y . forceUpdate ( ) ;
@@ -794,11 +804,14 @@ describe('ReactLegacyUpdates', () => {
794804 }
795805
796806 ReactDOM . unstable_batchedUpdates ( function ( ) {
797- ReactTestUtils . renderIntoDocument (
807+ const container = document . createElement ( 'div' ) ;
808+
809+ ReactDOM . render (
798810 < div >
799811 < A />
800812 < B />
801813 </ div > ,
814+ container ,
802815 ) ;
803816 } ) ;
804817
@@ -859,7 +872,8 @@ describe('ReactLegacyUpdates', () => {
859872 }
860873 }
861874
862- const component = ReactTestUtils . renderIntoDocument ( < A /> ) ;
875+ const container = document . createElement ( 'div' ) ;
876+ const component = ReactDOM . render ( < A /> , container ) ;
863877
864878 ReactDOM . unstable_batchedUpdates ( function ( ) {
865879 // B will have scheduled an update but the batching should ensure that its
@@ -886,7 +900,8 @@ describe('ReactLegacyUpdates', () => {
886900 }
887901 }
888902
889- let component = ReactTestUtils . renderIntoDocument ( < A /> ) ;
903+ let container = document . createElement ( 'div' ) ;
904+ let component = ReactDOM . render ( < A /> , container ) ;
890905
891906 expect ( ( ) => {
892907 expect ( ( ) => component . setState ( { } , 'no' ) ) . toErrorDev (
@@ -897,7 +912,8 @@ describe('ReactLegacyUpdates', () => {
897912 'Invalid argument passed as callback. Expected a function. Instead ' +
898913 'received: no' ,
899914 ) ;
900- component = ReactTestUtils . renderIntoDocument ( < A /> ) ;
915+ container = document . createElement ( 'div' ) ;
916+ component = ReactDOM . render ( < A /> , container ) ;
901917 expect ( ( ) => {
902918 expect ( ( ) => component . setState ( { } , { foo : 'bar' } ) ) . toErrorDev (
903919 'Expected the last optional `callback` argument to be ' +
@@ -908,7 +924,8 @@ describe('ReactLegacyUpdates', () => {
908924 'received: [object Object]' ,
909925 ) ;
910926 // 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 ) ;
912929 expect ( ( ) => component . setState ( { } , new Foo ( ) ) ) . toThrowError (
913930 'Invalid argument passed as callback. Expected a function. Instead ' +
914931 'received: [object Object]' ,
@@ -930,7 +947,8 @@ describe('ReactLegacyUpdates', () => {
930947 }
931948 }
932949
933- let component = ReactTestUtils . renderIntoDocument ( < A /> ) ;
950+ let container = document . createElement ( 'div' ) ;
951+ let component = ReactDOM . render ( < A /> , container ) ;
934952
935953 expect ( ( ) => {
936954 expect ( ( ) => component . forceUpdate ( 'no' ) ) . toErrorDev (
@@ -941,7 +959,8 @@ describe('ReactLegacyUpdates', () => {
941959 'Invalid argument passed as callback. Expected a function. Instead ' +
942960 'received: no' ,
943961 ) ;
944- component = ReactTestUtils . renderIntoDocument ( < A /> ) ;
962+ container = document . createElement ( 'div' ) ;
963+ component = ReactDOM . render ( < A /> , container ) ;
945964 expect ( ( ) => {
946965 expect ( ( ) => component . forceUpdate ( { foo : 'bar' } ) ) . toErrorDev (
947966 'Expected the last optional `callback` argument to be ' +
@@ -952,7 +971,8 @@ describe('ReactLegacyUpdates', () => {
952971 'received: [object Object]' ,
953972 ) ;
954973 // 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 ) ;
956976 expect ( ( ) => component . forceUpdate ( new Foo ( ) ) ) . toThrowError (
957977 'Invalid argument passed as callback. Expected a function. Instead ' +
958978 'received: [object Object]' ,
@@ -1004,7 +1024,8 @@ describe('ReactLegacyUpdates', () => {
10041024 }
10051025 }
10061026
1007- const parent = ReactTestUtils . renderIntoDocument ( < Parent /> ) ;
1027+ const container = document . createElement ( 'div' ) ;
1028+ const parent = ReactDOM . render ( < Parent /> , container ) ;
10081029 const child = parent . getChild ( ) ;
10091030 ReactDOM . unstable_batchedUpdates ( function ( ) {
10101031 parent . forceUpdate ( ) ;
0 commit comments