@uva-glass/component-library
Version:
React components UvA
91 lines (90 loc) • 2.6 kB
JavaScript
import { jsx as l } from "react/jsx-runtime";
import "../../index-dmBn99rF.js";
import { r as c, s as e } from "../../react.esm-DI5ilWeT.js";
import { CheckboxButtonBar as a } from "./CheckboxButtonBar.js";
const n = jest.fn(), x = [
{
label: "1.1",
value: "1"
},
{
label: "1.2",
value: "2"
},
{
label: "1.3",
value: "3"
}
];
describe("CheckboxButton", () => {
it("should render", () => {
c(
/* @__PURE__ */ l(
a,
{
label: "Periode",
checkboxes: x,
defaultValues: ["1", "2"],
labelPosition: "top",
onSetValues: n
}
)
), expect(e.getByText("Periode")).toBeInTheDocument();
const t = e.getAllByRole("checkbox");
expect(t).toHaveLength(3);
}), it("should render required", () => {
c(
/* @__PURE__ */ l(
a,
{
label: "Periode",
required: !0,
checkboxes: x,
defaultValues: ["1", "2"],
labelPosition: "top",
onSetValues: n
}
)
);
const t = e.getByText("Periode");
expect(t).toHaveTextContent("Periode"), expect(t).toHaveClass("label--required");
const o = e.getAllByRole("checkbox");
expect(o).toHaveLength(3);
}), it("should render default checked", () => {
c(
/* @__PURE__ */ l(
a,
{
label: "Periode",
checkboxes: x,
defaultValues: ["1", "2"],
labelPosition: "top",
onSetValues: n
}
)
);
const t = e.getByText("Periode");
expect(t).toHaveTextContent("Periode");
const o = e.getAllByRole("checkbox");
expect(o).toHaveLength(3), expect(o[0]).toBeChecked(), expect(o[1]).toBeChecked(), expect(o[2]).not.toBeChecked();
}), it("should render notValidatedText and notValid style", () => {
c(
/* @__PURE__ */ l(
a,
{
label: "Periode",
notValidatedText: "Not Valid",
checkboxes: x,
defaultValues: ["1", "2"],
labelPosition: "top",
onSetValues: n
}
)
);
const t = e.getByText("Periode");
expect(t).toHaveTextContent("Periode"), expect(e.getByText("Not Valid")).toBeInTheDocument();
const o = e.getAllByRole("checkbox");
expect(o).toHaveLength(3), expect(e.getByText("1.1")).toHaveClass("checkbox-button--not-valid"), expect(e.getByText("1.2")).toHaveClass("checkbox-button--not-valid"), expect(e.getByText("1.3")).toHaveClass("checkbox-button--not-valid");
});
});
//# sourceMappingURL=CheckboxButtonBar.test.js.map