diff --git a/compat/test/browser/portals.test.js b/compat/test/browser/portals.test.js index 1dba912b48..00343b23bf 100644 --- a/compat/test/browser/portals.test.js +++ b/compat/test/browser/portals.test.js @@ -428,4 +428,30 @@ describe('Portal', () => { expect(spyParent).to.be.calledOnce; expect(spy).to.be.calledOnce; }); + + it('should switch between non portal and portal node', () => { + let toggle; + const Modal = ({ children, open }) => open + ? createPortal(
{children}
, scratch) + :
Closed
; + + const App = () => { + const [open, setOpen] = useState(false); + toggle = setOpen.bind(this, (x) => !x); + return ( +
+ + {open ? 'Open' : 'Closed'} + Hello +
+ ); + }; + + render(, scratch); + expect(scratch.innerHTML).to.equal('
Closed
Closed
'); + + toggle(); + rerender(); + expect(scratch.innerHTML).to.equal('
Hello
Open
'); + }); });