10
10
'use strict' ;
11
11
12
12
let React ;
13
- let ReactDOM ;
14
13
let ReactDOMClient ;
15
14
let ReactTestUtils ;
16
15
let act ;
@@ -19,7 +18,6 @@ describe('ReactIdentity', () => {
19
18
beforeEach ( ( ) => {
20
19
jest . resetModules ( ) ;
21
20
React = require ( 'react' ) ;
22
- ReactDOM = require ( 'react-dom' ) ;
23
21
ReactDOMClient = require ( 'react-dom/client' ) ;
24
22
ReactTestUtils = require ( 'react-dom/test-utils' ) ;
25
23
act = require ( 'internal-test-utils' ) . act ;
@@ -260,18 +258,15 @@ describe('ReactIdentity', () => {
260
258
< TestContainer first = { instance0 } second = { instance1 } ref = { wrappedRef } /> ,
261
259
) ;
262
260
} ) ;
263
- const wrapped = wrappedRef . current ;
264
- // There isn't an alternative to findDOMNode for this:
265
- // https://react.dev/reference/react-dom/findDOMNode#alternatives
266
- const div = ReactDOM . findDOMNode ( wrapped ) ;
261
+ const div = container . firstChild ;
267
262
268
- const beforeA = div . childNodes [ 0 ] ;
269
- const beforeB = div . childNodes [ 1 ] ;
263
+ const beforeA = div . firstChild ;
264
+ const beforeB = div . lastChild ;
270
265
await act ( async ( ) => {
271
- wrapped . swap ( ) ;
266
+ wrappedRef . current . swap ( ) ;
272
267
} ) ;
273
- const afterA = div . childNodes [ 1 ] ;
274
- const afterB = div . childNodes [ 0 ] ;
268
+ const afterA = div . lastChild ;
269
+ const afterB = div . firstChild ;
275
270
276
271
expect ( beforeA ) . toBe ( afterA ) ;
277
272
expect ( beforeB ) . toBe ( afterB ) ;
0 commit comments