@@ -25,7 +25,8 @@ import Wedge from 'react-art/Wedge';
25
25
// Isolate DOM renderer.
26
26
jest . resetModules ( ) ;
27
27
const ReactDOM = require ( 'react-dom' ) ;
28
- const ReactTestUtils = require ( 'react-dom/test-utils' ) ;
28
+ const ReactDOMClient = require ( 'react-dom/client' ) ;
29
+ const act = require ( 'internal-test-utils' ) . act ;
29
30
30
31
// Isolate test renderer.
31
32
jest . resetModules ( ) ;
@@ -42,6 +43,7 @@ let Surface;
42
43
let TestComponent ;
43
44
44
45
let waitFor ;
46
+ let groupRef ;
45
47
46
48
const Missing = { } ;
47
49
@@ -82,8 +84,9 @@ describe('ReactART', () => {
82
84
83
85
( { waitFor} = require ( 'internal-test-utils' ) ) ;
84
86
87
+ groupRef = React . createRef ( ) ;
85
88
TestComponent = class extends React . Component {
86
- group = React . createRef ( ) ;
89
+ group = groupRef ;
87
90
88
91
render ( ) {
89
92
const a = (
@@ -132,17 +135,23 @@ describe('ReactART', () => {
132
135
container = null ;
133
136
} ) ;
134
137
135
- it ( 'should have the correct lifecycle state' , ( ) => {
136
- let instance = < TestComponent /> ;
137
- instance = ReactTestUtils . renderIntoDocument ( instance ) ;
138
- const group = instance . group . current ;
138
+ it ( 'should have the correct lifecycle state' , async ( ) => {
139
+ const instance = < TestComponent /> ;
140
+ const root = ReactDOMClient . createRoot ( container ) ;
141
+ await act ( ( ) => {
142
+ root . render ( instance ) ;
143
+ } ) ;
144
+ const group = groupRef . current ;
139
145
// Duck type test for an ART group
140
146
expect ( typeof group . indicate ) . toBe ( 'function' ) ;
141
147
} ) ;
142
148
143
- it ( 'should render a reasonable SVG structure in SVG mode' , ( ) => {
144
- let instance = < TestComponent /> ;
145
- instance = ReactTestUtils . renderIntoDocument ( instance ) ;
149
+ it ( 'should render a reasonable SVG structure in SVG mode' , async ( ) => {
150
+ const instance = < TestComponent /> ;
151
+ const root = ReactDOMClient . createRoot ( container ) ;
152
+ await act ( ( ) => {
153
+ root . render ( instance ) ;
154
+ } ) ;
146
155
147
156
const expectedStructure = {
148
157
nodeName : 'svg' ,
@@ -165,7 +174,7 @@ describe('ReactART', () => {
165
174
] ,
166
175
} ;
167
176
168
- const realNode = ReactDOM . findDOMNode ( instance ) ;
177
+ const realNode = container . firstChild ;
169
178
testDOMNodeStructure ( realNode , expectedStructure ) ;
170
179
} ) ;
171
180
@@ -243,7 +252,7 @@ describe('ReactART', () => {
243
252
ReactDOM . unmountComponentAtNode ( container ) ;
244
253
} ) ;
245
254
246
- it ( 'renders composite with lifecycle inside group' , ( ) => {
255
+ it ( 'renders composite with lifecycle inside group' , async ( ) => {
247
256
let mounted = false ;
248
257
249
258
class CustomShape extends React . Component {
@@ -255,18 +264,20 @@ describe('ReactART', () => {
255
264
mounted = true ;
256
265
}
257
266
}
258
-
259
- ReactTestUtils . renderIntoDocument (
260
- < Surface >
261
- < Group >
262
- < CustomShape />
263
- </ Group >
264
- </ Surface > ,
265
- ) ;
267
+ const root = ReactDOMClient . createRoot ( container ) ;
268
+ await act ( ( ) => {
269
+ root . render (
270
+ < Surface >
271
+ < Group >
272
+ < CustomShape />
273
+ </ Group >
274
+ </ Surface > ,
275
+ ) ;
276
+ } ) ;
266
277
expect ( mounted ) . toBe ( true ) ;
267
278
} ) ;
268
279
269
- it ( 'resolves refs before componentDidMount' , ( ) => {
280
+ it ( 'resolves refs before componentDidMount' , async ( ) => {
270
281
class CustomShape extends React . Component {
271
282
render ( ) {
272
283
return < Shape /> ;
@@ -293,7 +304,10 @@ describe('ReactART', () => {
293
304
}
294
305
}
295
306
296
- ReactTestUtils . renderIntoDocument ( < Outer /> ) ;
307
+ const root = ReactDOMClient . createRoot ( container ) ;
308
+ await act ( ( ) => {
309
+ root . render ( < Outer /> ) ;
310
+ } ) ;
297
311
expect ( ref . constructor ) . toBe ( CustomShape ) ;
298
312
} ) ;
299
313
0 commit comments