@uva-glass/component-library
Version:
React components UvA
34 lines (33 loc) • 2.34 kB
JavaScript
import { jsx as n } from "react/jsx-runtime";
import "../../index-dmBn99rF.js";
import { r as c, s as e, f as s, w as d } from "../../react.esm-DI5ilWeT.js";
import { u as r } from "../../index-hwMTfLfH.js";
import { AccordionCard as a } from "./AccordionCard.js";
describe("AccordionCard", () => {
it("should render", () => {
c(/* @__PURE__ */ n(a, { title: "Test Accordion Card", content: "TestComponent", expanded: !0 })), expect(e.getByText("Test Accordion Card")).toBeInTheDocument(), expect(e.getByText("TestComponent")).toBeInTheDocument();
}), it("should display content when expanded by default", () => {
c(/* @__PURE__ */ n(a, { title: "Test Accordion Card", content: "TestComponent", expanded: !0 })), expect(e.getByText("Test Accordion Card")).toBeInTheDocument(), expect(e.getByText("TestComponent")).toHaveClass("accordion-card__content--expanded");
}), it("should toggle content visibility on click", () => {
c(/* @__PURE__ */ n(a, { title: "Test Accordion Card", content: "TestComponent" }));
const o = e.getByText("Test Accordion Card"), t = e.getByText("TestComponent");
expect(o).toBeInTheDocument(), s.click(o), expect(t).toHaveClass("accordion-card__content--expanded"), s.click(o), expect(t).not.toHaveClass("accordion-card__content--expanded");
}), it("should toggle content visibility on Enter key press", async () => {
c(/* @__PURE__ */ n(a, { title: "Test Accordion Card", content: "TestComponent" }));
const o = e.getByRole("button"), t = e.getByText("TestComponent");
o.focus(), await r.keyboard("[Enter]"), await d(() => {
expect(t).toHaveClass("accordion-card__content--expanded");
}), await r.keyboard("[Enter]"), await d(() => {
expect(t).not.toHaveClass("accordion-card__content--expanded");
});
}), it("should toggle content visibility on Space key press", async () => {
c(/* @__PURE__ */ n(a, { title: "Test Accordion Card", content: "TestComponent" }));
const o = e.getByRole("button"), t = e.getByText("TestComponent");
o.focus(), await r.keyboard("[Space]"), await d(() => {
expect(t).toHaveClass("accordion-card__content--expanded");
}), await r.keyboard("[Space]"), await d(() => {
expect(t).not.toHaveClass("accordion-card__content--expanded");
});
});
});
//# sourceMappingURL=AccordionCard.test.js.map