Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Commit f1e7580

Browse files
committed
Add portal test
1 parent d4be565 commit f1e7580

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

cypress/integration/portal-spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from "react";
2+
import ReactDOM from "react-dom";
3+
import { mount } from "cypress-react-unit-tests";
4+
5+
const RenderInPortal = ({ children }) => {
6+
return ReactDOM.createPortal(children, document.body);
7+
};
8+
9+
const MyComponent = () => (
10+
<div id="component">
11+
<p>Hello World!</p>
12+
<RenderInPortal>
13+
<p> I am in portal </p>
14+
</RenderInPortal>
15+
</div>
16+
);
17+
18+
describe("Portals", () => {
19+
it("renders content inside the portal", () => {
20+
mount(<MyComponent />);
21+
22+
cy.contains("#component", "Hello World!");
23+
cy.get("#component").should("not.contain", "I am in portal");
24+
cy.get("body").contains("I am in portal");
25+
});
26+
});

0 commit comments

Comments
 (0)