@crossed/primitive
Version:
A universal & performant styling library for React Native, Next.js & React
39 lines (38 loc) • 1.36 kB
JavaScript
import { jsx } from "react/jsx-runtime";
import { render, screen } from "@crossed/test";
import { VisibilityHidden } from "../VisibilityHidden";
describe("VisibilityHidden", () => {
const oldError = console.error;
beforeEach(() => {
console.error = jest.fn();
});
afterEach(() => {
console.error = oldError;
});
test("children is string", () => {
try {
render(/* @__PURE__ */ jsx(VisibilityHidden, { children: "hello" }));
} catch (e) {
expect(e.message).toBe(`"VisibilityHidden" not accept string children`);
}
});
test("show", async () => {
render(
/* @__PURE__ */ jsx(VisibilityHidden, { children: /* @__PURE__ */ jsx("div", { role: "main" }) })
);
const child = await screen.getByRole("main");
expect(child).toHaveAttribute("aria-hidden", "false");
});
test("hidden", async () => {
render(
/* @__PURE__ */ jsx(VisibilityHidden, { hidden: true, children: /* @__PURE__ */ jsx("div", { role: "main" }) })
);
const child = await screen.getByRole("main", { hidden: true });
expect(child).toHaveAttribute("aria-hidden", "true");
expect(child).toHaveAttribute(
"style",
"position: absolute; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; word-wrap: normal;"
);
});
});
//# sourceMappingURL=VisibilityHidden.spec.js.map