@uva-glass/component-library
Version:
React components UvA
33 lines (32 loc) • 1.57 kB
JavaScript
import { jsx as o, jsxs as d, Fragment as r } from "react/jsx-runtime";
import "../../index-DYPpFe2R.js";
import { r as n, s as t, f as a } from "../../react.esm-DdELhthz.js";
import { MultiSelectBox as l } from "./MultiSelectBox.js";
const i = jest.fn(), c = [
{ label: "Option 1", value: "1" },
{ label: "Option 2", value: "2" },
{ label: "Option 3", value: "3" }
];
describe("MultiSelectBox", () => {
it("renders the component with default props", () => {
n(/* @__PURE__ */ o(l, { selectData: c, onChange: i, labelSuffix: "selected" }));
const e = t.getByRole("button");
expect(e).toBeInTheDocument(), expect(e).toHaveAttribute("aria-expanded", "false");
}), it("opens the dropdown when the button is clicked", () => {
n(/* @__PURE__ */ o(l, { selectData: c, onChange: i, labelSuffix: "selected" }));
const e = t.getByRole("button");
a.click(e), expect(e).toHaveAttribute("aria-expanded", "true"), expect(t.getByRole("listbox")).toBeInTheDocument();
}), it("closes the dropdown when clicking outside", () => {
n(
/* @__PURE__ */ d(r, { children: [
/* @__PURE__ */ o(l, { selectData: c, onChange: i, labelSuffix: "selected" }),
/* @__PURE__ */ o("div", { "data-testid": "outside-element", children: "Outside" })
] })
);
const e = t.getByRole("button");
a.click(e), expect(e).toHaveAttribute("aria-expanded", "true");
const s = t.getByTestId("outside-element");
a.click(s), expect(e).toHaveAttribute("aria-expanded", "false");
});
});
//# sourceMappingURL=MultiSelectBox.test.js.map