import { jsx } from "react/jsx-runtime";
import React from "react";
import { render, fireEvent } from "@testing-library/react";
import Checkbox from "..";
import ThemeProvider from "../../Theme";
describe("<Checkbox />", () => {
  describe("<Checkbox.Switch />", () => {
    describe("Snapshots", () => {
      it("should match snapshot with default switch", () => {
        const { container } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox.Switch, {}) })
        );
        expect(container).toMatchSnapshot();
      });
      it("should match snapshot with disabled switch", () => {
        const { container } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox.Switch, { disabled: true }) })
        );
        expect(container).toMatchSnapshot();
      });
      it("should match snapshot with checked switch", () => {
        const { container } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox.Switch, { checked: true }) })
        );
        expect(container).toMatchSnapshot();
      });
      it("should match snapshot with disabled and checked switch", () => {
        const { container } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox.Switch, { disabled: true, checked: true }) })
        );
        expect(container).toMatchSnapshot();
      });
      it("should call onChange function when click on Checkbox.Switch", () => {
        const onChangeMock = jest.fn();
        const { getByRole } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox.Switch, { disabled: true, checked: true, onChange: onChangeMock }) })
        );
        fireEvent.click(getByRole("switch", { hidden: true }));
        expect(onChangeMock).toHaveBeenCalled();
      });
    });
  });
});
