@crossed/ui
Version:
A universal & performant styling library for React Native, Next.js & React
27 lines (26 loc) • 1.18 kB
JavaScript
var import_jsx_runtime = require("react/jsx-runtime");
var import__ = require("../index");
var import_test = require("@crossed/test");
describe("Switch", () => {
test("Simple render", () => {
const onChange = jest.fn();
(0, import_test.render)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Switch, { onChange, children: "Simple" }));
const switchComp = import_test.screen.getByRole("switch");
expect(switchComp).toHaveAttribute("aria-checked", "false");
import_test.fireEvent.click(switchComp);
expect(onChange).toHaveBeenCalled();
expect(switchComp).toHaveAttribute("aria-checked", "true");
});
test("Disabled", () => {
const onChange = jest.fn();
(0, import_test.render)(
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Switch, { onChange, disabled: true, children: "Simple" })
);
const switchComp = import_test.screen.getByRole("switch");
expect(switchComp).toHaveAttribute("aria-checked", "false");
import_test.fireEvent.click(switchComp);
expect(switchComp).toHaveAttribute("aria-checked", "false");
expect(onChange).not.toHaveBeenCalled();
});
});
//# sourceMappingURL=Switch.spec.js.map