@uva-glass/component-library
Version:
React components UvA
25 lines (24 loc) • 1.25 kB
JavaScript
import { jsx as n } from "react/jsx-runtime";
import "../../index-dmBn99rF.js";
import { r as l, s as t, f as s } from "../../react.esm-DI5ilWeT.js";
import { RadioGroup as a } from "./RadioGroup.js";
const i = [
{ id: "1", titleLabel: "Option 1", value: "option1" },
{ id: "2", titleLabel: "Option 2", value: "option2" }
];
describe("RadioGroup", () => {
it("should render correctly", () => {
l(/* @__PURE__ */ n(a, { label: "Test Label", options: i, onChange: jest.fn() })), expect(t.getByText("Test Label")).toBeInTheDocument(), expect(t.getByText("Option 1")).toBeInTheDocument(), expect(t.getByText("Option 2")).toBeInTheDocument();
}), it("should call onChange when an option is selected", () => {
const e = jest.fn();
l(/* @__PURE__ */ n(a, { label: "Test Label", options: i, onChange: e }));
const o = t.getByLabelText("Option 1");
s.click(o), expect(e).toHaveBeenCalledWith("option1");
}), it("should not allow selection when disabled", () => {
const e = jest.fn();
l(/* @__PURE__ */ n(a, { label: "Test Label", options: i, onChange: e, disabled: !0 }));
const o = t.getByLabelText("Option 1");
s.click(o), expect(e).not.toHaveBeenCalled();
});
});
//# sourceMappingURL=Radiogroup.test.js.map