var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
import { jsx } from "react/jsx-runtime";
import React from "react";
import { render, fireEvent } from "@testing-library/react";
import Checkbox from "..";
import ThemeProvider from "../../Theme";
jest.mock("../../hooks/useId", () => ({
  useId: () => "jest-id"
}));
const data = {
  label: "Checkbox Component",
  helper: "Helper Text"
};
const originalError = console.error;
beforeEach(() => {
  console.error = jest.fn();
});
afterEach(() => {
  console.error = originalError;
});
describe("<Checkbox />", () => {
  describe("Snapshots", () => {
    it("should match snapshot without props", () => {
      const { container } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, {}) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match snapshot with default checkbox", () => {
      const { container } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, __spreadValues({}, data)) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match snapshot with disabled checkbox", () => {
      const { container } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, data), { disabled: true })) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match snapshot with checked checkbox", () => {
      const { container } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, data), { checked: true })) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match snapshot with disabled and checked checkbox", () => {
      const { container } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, data), { disabled: true, checked: true })) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match snapshot with error checkbox", () => {
      const { container } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, data), { error: "Error msg" })) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match snapshot with error and checked checkbox", () => {
      const { container } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, data), { error: "Error msg", checked: true })) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match snapshot with inverted", () => {
      const { container } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, data), { inverted: true })) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match snapshot with inverted and checked", () => {
      const { container } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, data), { inverted: true, checked: true })) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match snapshot with inverted and checked and disabled", () => {
      const { container } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, data), { inverted: true, checked: true, disabled: true })) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match snapshot with indeterminate", () => {
      const { container } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, { indeterminate: true }) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match snapshot with indeterminate and disabled checkbox", () => {
      const { container } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, { indeterminate: true, disabled: true }) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match snapshot with error and indeterminate checkbox", () => {
      const { container } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, data), { error: "Error msg", indeterminate: true })) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match snapshot with inverted and indeterminate", () => {
      const { container } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, data), { inverted: true, indeterminate: true })) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match snapshot with a given value", () => {
      const { container } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, data), { value: "test_value" })) })
      );
      expect(container).toMatchSnapshot();
    });
  });
  describe("Events", () => {
    it("should call onChange function when press on Checkbox", () => {
      const onChangeMock = jest.fn();
      const { getByTestId } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, data), { onChange: onChangeMock })) })
      );
      fireEvent.click(getByTestId("checkbox-checkMark"));
      expect(onChangeMock).toHaveBeenCalled();
    });
  });
});
