UNPKG

@uva-glass/component-library

Version:

React components UvA

61 lines (60 loc) 4.03 kB
import { jsx as i } from "react/jsx-runtime"; import "../../index-dmBn99rF.js"; import { r as n, s as t, w as a } from "../../react.esm-CMg7bmSn.js"; import { u as l } from "../../index-Ck15_vKo.js"; import { ActionList as o } from "./ActionList.js"; const T = jest.fn(), c = [ /* @__PURE__ */ i("button", { type: "button", onClick: T, children: "Test Action 1" }, "1"), /* @__PURE__ */ i("button", { type: "button", children: "Test Action 2" }, "2"), /* @__PURE__ */ i("button", { type: "button", children: "Test Action 3" }, "3") ]; describe("ActionList", () => { it("should render (variant primary)", () => { n( /* @__PURE__ */ i(o, { label: "Test ActionList", variant: "primary", iconName: "EllipsisVertical", children: c.map((e) => e) }) ), expect(t.getByText("Test ActionList")).toBeInTheDocument(), expect(t.getByText("Test ActionList")).toHaveClass("button--primary"), expect(t.getByText("Test Action 1")).toBeInTheDocument(), expect(t.getByText("Test Action 2")).toBeInTheDocument(), expect(t.getByText("Test Action 3")).toBeInTheDocument(); }), it("should render variant secondary", () => { n( /* @__PURE__ */ i(o, { label: "Test ActionList", variant: "secondary", iconName: "EllipsisVertical", children: c.map((e) => e) }) ), expect(t.getByText("Test ActionList")).toBeInTheDocument(), expect(t.getByText("Test ActionList")).toHaveClass("button--secondary"); }), it("should render variant destructive-primary", () => { n( /* @__PURE__ */ i(o, { label: "Test ActionList", variant: "destructive-primary", iconName: "EllipsisVertical", children: c.map((e) => e) }) ), expect(t.getByText("Test ActionList")).toBeInTheDocument(), expect(t.getByText("Test ActionList")).toHaveClass("button--destructive-primary"); }), it("should render variant destructive-secondary", () => { n( /* @__PURE__ */ i(o, { label: "Test ActionList", variant: "destructive-secondary", iconName: "EllipsisVertical", children: c.map((e) => e) }) ), expect(t.getByText("Test ActionList")).toBeInTheDocument(), expect(t.getByText("Test ActionList")).toHaveClass("button--destructive-secondary"); }), it("should render variant blank", () => { n( /* @__PURE__ */ i(o, { label: "Test ActionList", variant: "blank", iconName: "EllipsisVertical", children: c.map((e) => e) }) ), expect(t.getByText("Test ActionList")).toBeInTheDocument(), expect(t.getByText("Test ActionList")).toHaveClass("button--blank"); }), it("should render variant blank-icon", () => { n( /* @__PURE__ */ i(o, { label: "Test ActionList", variant: "blank-icon", iconName: "EllipsisVertical", children: c.map((e) => e) }) ), expect(t.getByText("Test ActionList")).toBeInTheDocument(), expect(t.getByText("Test ActionList")).toHaveClass("button--blank-icon"); }), it("should toggle content visibility on click", async () => { n( /* @__PURE__ */ i(o, { label: "Test ActionList", variant: "blank-icon", iconName: "EllipsisVertical", children: c.map((r) => r) }) ); const e = t.getByText("Test ActionList"), s = t.getByRole("menu"); expect(e).toBeInTheDocument(), expect(s).toBeInTheDocument(), await l.click(e), await a(() => { expect(s).toHaveClass("action-list--open"); }), await l.click(e), await a(() => { expect(s).not.toHaveClass("action-list--open"); }); }), it("should fire action on click on action button", async () => { n( /* @__PURE__ */ i(o, { label: "Test ActionList", variant: "blank-icon", iconName: "EllipsisVertical", children: c.map((p) => p) }) ); const e = t.getByText("Test ActionList"), s = t.getByRole("menu"); expect(e).toBeInTheDocument(), expect(s).toBeInTheDocument(), await l.click(e), await a(() => { expect(s).toHaveClass("action-list--open"); }); const r = t.getByText("Test Action 1"); await l.click(r), expect(T).toHaveBeenCalledTimes(1), await a(() => { expect(s).not.toHaveClass("action-list--open"); }); }); }); //# sourceMappingURL=ActionList.test.js.map