File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
packages/react-dom/src/__tests__ Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 1111
1212describe ( 'ReactDOMIframe' , ( ) => {
1313 let React ;
14- let ReactTestUtils ;
14+ let ReactDOMClient ;
15+ let act ;
1516
1617 beforeEach ( ( ) => {
1718 React = require ( 'react' ) ;
18- ReactTestUtils = require ( 'react-dom/test-utils' ) ;
19+ ReactDOMClient = require ( 'react-dom/client' ) ;
20+ act = require ( 'internal-test-utils' ) . act ;
1921 } ) ;
2022
21- it ( 'should trigger load events' , ( ) => {
23+ it ( 'should trigger load events' , async ( ) => {
2224 const onLoadSpy = jest . fn ( ) ;
23- let iframe = React . createElement ( 'iframe' , { onLoad : onLoadSpy } ) ;
24- iframe = ReactTestUtils . renderIntoDocument ( iframe ) ;
25+ const container = document . createElement ( 'div' ) ;
26+ const root = ReactDOMClient . createRoot ( container ) ;
27+ await act ( ( ) => {
28+ root . render ( React . createElement ( 'iframe' , { onLoad : onLoadSpy } ) ) ;
29+ } ) ;
30+ const iframe = container . firstChild ;
2531
2632 const loadEvent = document . createEvent ( 'Event' ) ;
2733 loadEvent . initEvent ( 'load' , false , false ) ;
2834
29- iframe . dispatchEvent ( loadEvent ) ;
35+ await act ( ( ) => {
36+ iframe . dispatchEvent ( loadEvent ) ;
37+ } ) ;
3038
3139 expect ( onLoadSpy ) . toHaveBeenCalled ( ) ;
3240 } ) ;
You can’t perform that action at this time.
0 commit comments