UNPKG

@uva-glass/component-library

Version:

React components UvA

30 lines (29 loc) 2.01 kB
import { jsx as o } from "react/jsx-runtime"; import "../../index-dmBn99rF.js"; import { r as n, s as a } from "../../react.esm-DI5ilWeT.js"; import { u as e } from "../../index-hwMTfLfH.js"; import { Accordion as i } from "./Accordion.js"; describe("Accordion", () => { it("should render", () => { n(/* @__PURE__ */ o(i, { title: "Test Accordion", content: "Test Content" })); const t = a.getByText("Test Accordion"); expect(t).toBeInTheDocument(), expect(t).toHaveAttribute("aria-expanded", "false"); }), it("should display content when expanded by default", () => { n(/* @__PURE__ */ o(i, { title: "Test Accordion", content: "Test Content", expanded: !0 })); const t = a.getByText("Test Accordion"); expect(t).toBeInTheDocument(), expect(t).toHaveAttribute("aria-expanded", "true"); }), it("should toggle content visibility on click", async () => { n(/* @__PURE__ */ o(i, { title: "Test Accordion", content: "Test Content" })); const t = a.getByText("Test Accordion"); await e.click(t), expect(t).toHaveAttribute("aria-expanded", "true"), await e.click(t), expect(t).toHaveAttribute("aria-expanded", "false"); }), it("should toggle content visibility on Enter key press", async () => { n(/* @__PURE__ */ o(i, { title: "Test Accordion", content: "Test Content" })); const t = a.getByText("Test Accordion"); await e.keyboard("[Tab]"), await e.keyboard("[Enter]"), expect(t).toHaveAttribute("aria-expanded", "true"), await e.keyboard("[Enter]"), expect(t).toHaveAttribute("aria-expanded", "false"); }), it("should toggle content visibility on Space key press", async () => { n(/* @__PURE__ */ o(i, { title: "Test Accordion", content: "Test Content" })); const t = a.getByText("Test Accordion"); await e.keyboard("[Tab]"), await e.keyboard("[Space]"), expect(t).toHaveAttribute("aria-expanded", "true"), await e.keyboard("[Space]"), expect(t).toHaveAttribute("aria-expanded", "false"); }); }); //# sourceMappingURL=Accordion.test.js.map