UNPKG

@kiwicom/orbit-components

Version:

<div align="center"> <a href="https://orbit.kiwi" target="_blank"> <img alt="orbit-components" src="https://orbit.kiwi/wp-content/uploads/2018/08/orbit-components.png" srcset="https://orbit.kiwi/wp-content/uploads/2018/08/orbit-components@2x.png 2x"

44 lines (40 loc) 1.19 kB
// @flow strict import * as React from "react"; import { mount } from "enzyme"; import Portal from "../index"; describe("Portal with element", () => { const target = document.createElement("div"); target.setAttribute("id", "portal"); // $FlowIssue document.body.appendChild(target); const component = mount( <Portal element="portal"> <p>Content</p> </Portal>, ); it("should match snapshot", () => { expect(document.getElementById("portal")).toMatchSnapshot(); expect(component).toMatchSnapshot(); }); it("unmouted, should match snapshot", () => { component.unmount(); expect(document.getElementById("portal")).toMatchSnapshot(); expect(component).toMatchSnapshot(); }); }); describe("Portal without element", () => { const component = mount( <Portal> <p>Content</p> </Portal>, ); it("should match snapshot", () => { expect(document.getElementById("modal")).toMatchSnapshot(); expect(component).toMatchSnapshot(); }); it("unmouted, should match snapshot", () => { component.unmount(); expect(document.getElementById("modal")).toMatchSnapshot(); expect(component).toMatchSnapshot(); }); });