1111
1212let React ;
1313let ReactDOMClient ;
14- let ReactTestUtils ;
1514let act ;
1615
1716// TODO: Historically this module was used to confirm that the JSX transform
@@ -30,7 +29,6 @@ describe('ReactJSXTransformIntegration', () => {
3029
3130 React = require ( 'react' ) ;
3231 ReactDOMClient = require ( 'react-dom/client' ) ;
33- ReactTestUtils = require ( 'react-dom/test-utils' ) ;
3432 act = require ( 'internal-test-utils' ) . act ;
3533
3634 Component = class extends React . Component {
@@ -213,22 +211,34 @@ describe('ReactJSXTransformIntegration', () => {
213211 expect ( instance . props . fruit ) . toBe ( 'persimmon' ) ;
214212 } ) ;
215213
216- it ( 'should normalize props with default values' , ( ) => {
214+ it ( 'should normalize props with default values' , async ( ) => {
217215 class NormalizingComponent extends React . Component {
218216 render ( ) {
219217 return < span > { this . props . prop } </ span > ;
220218 }
221219 }
222220 NormalizingComponent . defaultProps = { prop : 'testKey' } ;
223221
224- const instance = ReactTestUtils . renderIntoDocument (
225- < NormalizingComponent /> ,
226- ) ;
222+ let container = document . createElement ( 'div' ) ;
223+ let root = ReactDOMClient . createRoot ( container ) ;
224+ let instance ;
225+ await act ( ( ) => {
226+ root . render (
227+ < NormalizingComponent ref = { current => ( instance = current ) } /> ,
228+ ) ;
229+ } ) ;
230+
227231 expect ( instance . props . prop ) . toBe ( 'testKey' ) ;
228232
229- const inst2 = ReactTestUtils . renderIntoDocument (
230- < NormalizingComponent prop = { null } /> ,
231- ) ;
233+ container = document . createElement ( 'div' ) ;
234+ root = ReactDOMClient . createRoot ( container ) ;
235+ let inst2 ;
236+ await act ( ( ) => {
237+ root . render (
238+ < NormalizingComponent prop = { null } ref = { current => ( inst2 = current ) } /> ,
239+ ) ;
240+ } ) ;
241+
232242 expect ( inst2 . props . prop ) . toBe ( null ) ;
233243 } ) ;
234244} ) ;
0 commit comments