@crossed/ui
Version:
A universal & performant styling library for React Native, Next.js & React
27 lines (26 loc) • 1.02 kB
JavaScript
import { jsx } from "react/jsx-runtime";
import { Checkbox } from "../index";
import { screen, render, fireEvent } from "@crossed/test";
describe("Checkbox", () => {
test("Simple render", () => {
const onPress = jest.fn();
render(/* @__PURE__ */ jsx(Checkbox, { onPress, children: "Simple" }));
const checkbox = screen.getByRole("checkbox");
expect(checkbox).toHaveAttribute("aria-checked", "false");
fireEvent.click(checkbox);
expect(checkbox).toHaveAttribute("aria-checked", "true");
expect(onPress).toHaveBeenCalled();
});
test("Disabled", () => {
const onPress = jest.fn();
render(
/* @__PURE__ */ jsx(Checkbox, { onPress, disabled: true, children: "Simple" })
);
const checkbox = screen.getByRole("checkbox");
expect(checkbox).toHaveAttribute("aria-checked", "false");
fireEvent.click(checkbox);
expect(checkbox).toHaveAttribute("aria-checked", "false");
expect(onPress).not.toHaveBeenCalled();
});
});
//# sourceMappingURL=Checkbox.spec.js.map