10
10
'use strict' ;
11
11
12
12
let React ;
13
- let ReactDOM ;
13
+ let ReactDOMClient ;
14
+ let act ;
14
15
15
16
let MockedComponent ;
16
17
let ReactDOMServer ;
17
18
18
19
describe ( 'ReactMockedComponent' , ( ) => {
19
20
beforeEach ( ( ) => {
20
21
React = require ( 'react' ) ;
21
- ReactDOM = require ( 'react-dom' ) ;
22
+ ReactDOMClient = require ( 'react-dom/client ' ) ;
22
23
ReactDOMServer = require ( 'react-dom/server' ) ;
24
+ act = require ( 'internal-test-utils' ) . act ;
23
25
24
26
MockedComponent = class extends React . Component {
25
27
render ( ) {
@@ -30,15 +32,23 @@ describe('ReactMockedComponent', () => {
30
32
MockedComponent . prototype . render = jest . fn ( ) ;
31
33
} ) ;
32
34
33
- it ( 'should allow a mocked component to be rendered' , ( ) => {
35
+ it ( 'should allow a mocked component to be rendered' , async ( ) => {
34
36
const container = document . createElement ( 'container' ) ;
35
- ReactDOM . render ( < MockedComponent /> , container ) ;
37
+ const root = ReactDOMClient . createRoot ( container ) ;
38
+ await act ( ( ) => {
39
+ root . render ( < MockedComponent /> ) ;
40
+ } ) ;
36
41
} ) ;
37
42
38
- it ( 'should allow a mocked component to be updated in dev' , ( ) => {
43
+ it ( 'should allow a mocked component to be updated in dev' , async ( ) => {
39
44
const container = document . createElement ( 'container' ) ;
40
- ReactDOM . render ( < MockedComponent /> , container ) ;
41
- ReactDOM . render ( < MockedComponent /> , container ) ;
45
+ const root = ReactDOMClient . createRoot ( container ) ;
46
+ await act ( ( ) => {
47
+ root . render ( < MockedComponent /> ) ;
48
+ } ) ;
49
+ await act ( ( ) => {
50
+ root . render ( < MockedComponent /> ) ;
51
+ } ) ;
42
52
} ) ;
43
53
44
54
it ( 'should allow a mocked component to be rendered in dev (SSR)' , ( ) => {
0 commit comments