@@ -15,6 +15,9 @@ import {
1515 sym ,
1616} from 'enzyme/build/Utils' ;
1717import getAdapter from 'enzyme/build/getAdapter' ;
18+ import {
19+ Portal ,
20+ } from 'react-is' ;
1821
1922import './_helpers/setupAdapters' ;
2023import {
@@ -36,9 +39,6 @@ import {
3639 REACT16 ,
3740 is ,
3841} from './_helpers/version' ;
39- import {
40- Portal ,
41- } from 'react-is' ;
4242import realArrowFunction from './_helpers/realArrowFunction' ;
4343import sloppyReturnThis from './_helpers/untranspiledSloppyReturnThis' ;
4444
@@ -386,11 +386,12 @@ describeWithDOM('mount', () => {
386386
387387 describeIf ( is ( '>= 16' ) , 'portals' , ( ) => {
388388 it ( 'should have portals in mount debug tree' , ( ) => {
389+ const containerDiv = global . document . createElement ( 'div' ) ;
389390 const Foo = ( ) => (
390391 < div >
391392 { createPortal (
392393 < div className = "in-portal" > InPortal</ div > ,
393- document . body
394+ containerDiv ,
394395 ) }
395396 </ div >
396397 ) ;
@@ -408,9 +409,10 @@ describeWithDOM('mount', () => {
408409 } ) ;
409410
410411 it ( 'should have top level portals in mount debug tree' , ( ) => {
412+ const containerDiv = global . document . createElement ( 'div' ) ;
411413 const Foo = ( ) => createPortal (
412414 < div className = "in-portal" > InPortal</ div > ,
413- document . body
415+ containerDiv ,
414416 ) ;
415417
416418 const wrapper = mount ( < Foo /> ) ;
@@ -1260,11 +1262,12 @@ describeWithDOM('mount', () => {
12601262 } ) ;
12611263
12621264 itIf ( is ( '>= 16' ) , 'should find mounted portals by name' , ( ) => {
1265+ const containerDiv = global . document . createElement ( 'div' ) ;
12631266 const Foo = ( ) => (
12641267 < div >
12651268 { createPortal (
12661269 < div className = "in-portal" > InPortal</ div > ,
1267- document . body
1270+ containerDiv ,
12681271 ) }
12691272 </ div >
12701273 ) ;
@@ -1600,11 +1603,12 @@ describeWithDOM('mount', () => {
16001603 } ) ;
16011604
16021605 itIf ( is ( '>= 16' ) , 'should find mounted portals by react-is Portal type' , ( ) => {
1606+ const containerDiv = global . document . createElement ( 'div' ) ;
16031607 const Foo = ( ) => (
16041608 < div >
16051609 { createPortal (
16061610 < div className = "in-portal" > InPortal</ div > ,
1607- document . body
1611+ containerDiv ,
16081612 ) }
16091613 </ div >
16101614 ) ;
0 commit comments