File tree 1 file changed +10
-5
lines changed
packages/react-dom/src/__tests__
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 10
10
'use strict' ;
11
11
12
12
let React = require ( 'react' ) ;
13
- const ReactTestUtils = require ( 'react-dom/test-utils' ) ;
13
+ const ReactDOMClient = require ( 'react-dom/client' ) ;
14
+ const act = require ( 'internal-test-utils' ) . act ;
14
15
15
16
class TextWithStringRef extends React . Component {
16
17
render ( ) {
@@ -21,10 +22,14 @@ class TextWithStringRef extends React.Component {
21
22
}
22
23
23
24
describe ( 'when different React version is used with string ref' , ( ) => {
24
- it ( 'throws the "Refs must have owner" warning' , ( ) => {
25
- expect ( ( ) => {
26
- ReactTestUtils . renderIntoDocument ( < TextWithStringRef /> ) ;
27
- } ) . toThrow (
25
+ it ( 'throws the "Refs must have owner" warning' , async ( ) => {
26
+ const container = document . createElement ( 'div' ) ;
27
+ const root = ReactDOMClient . createRoot ( container ) ;
28
+ await expect (
29
+ act ( ( ) => {
30
+ root . render ( < TextWithStringRef /> ) ;
31
+ } ) ,
32
+ ) . rejects . toThrow (
28
33
'Element ref was specified as a string (foo) but no owner was set. This could happen for one of' +
29
34
' the following reasons:\n' +
30
35
'1. You may be adding a ref to a function component\n' +
You can’t perform that action at this time.
0 commit comments