@crossed/ui
Version:
A universal & performant styling library for React Native, Next.js & React
40 lines (39 loc) • 1.28 kB
JavaScript
import { jsx } from "react/jsx-runtime";
import { render, screen } from "@crossed/test";
import { FloatingPortal } from "../Portal";
import { FloatingProvider } from "../context";
import { PortalProvider } from "@gorhom/portal";
describe("Floating.Portal", () => {
const mount = ({
open,
removeScroll,
visibilityHidden
}) => {
expect(FloatingPortal.displayName).toEqual("Floating.Portal");
const onClose = jest.fn();
const onOpen = jest.fn();
render(
/* @__PURE__ */ jsx(PortalProvider, { children: /* @__PURE__ */ jsx(
FloatingProvider,
{
onClose,
onOpen,
open: open ?? false,
removeScroll,
visibilityHidden,
children: /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx("div", { "data-testid": "children" }) })
}
) })
);
return { onClose, onOpen };
};
test("open with removescroll", async () => {
mount({ open: true, removeScroll: true });
expect(screen.getByTestId("children")).toBeTruthy();
});
test("open without removescroll", async () => {
mount({ open: true, removeScroll: false });
expect(() => screen.getByTestId("children")).toBeTruthy();
});
});
//# sourceMappingURL=Portal.spec.js.map