"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var import_jsx_runtime = require("react/jsx-runtime");
var import_react = __toESM(require("react"));
var import_react2 = require("@testing-library/react");
var import__ = require("../..");
describe("<Input.Password />", () => {
  describe("Snapshots", () => {
    it("should match with default input", () => {
      const { container } = (0, import_react2.render)(
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input.Password, {}) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match with disabled input", () => {
      const { container } = (0, import_react2.render)(
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input.Password, { disabled: true }) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match with full width", () => {
      const { container } = (0, import_react2.render)(
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input.Password, { label: "Label", full: true }) })
      );
      expect(container).toMatchSnapshot();
    });
  });
  describe("Events", () => {
    it("should call onChange", () => {
      const onChangeMock = jest.fn();
      const { getByTestId } = (0, import_react2.render)(
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
          import__.Input.Password,
          {
            label: "Input",
            "data-testid": "input",
            onChange: onChangeMock
          }
        ) })
      );
      import_react2.fireEvent.change(getByTestId("input"), { target: { value: "foo" } });
      expect(onChangeMock).toHaveBeenCalled();
    });
    it("should call onFocus", () => {
      const onFocusMock = jest.fn();
      const { getByTestId } = (0, import_react2.render)(
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
          import__.Input.Password,
          {
            label: "Input",
            "data-testid": "input",
            onFocus: onFocusMock
          }
        ) })
      );
      import_react2.fireEvent.focus(getByTestId("input"));
      expect(onFocusMock).toHaveBeenCalled();
    });
    it("should call onBlur", () => {
      const onBlurMock = jest.fn();
      const { getByTestId } = (0, import_react2.render)(
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
          import__.Input.Password,
          {
            label: "Input",
            "data-testid": "input",
            onBlur: onBlurMock
          }
        ) })
      );
      import_react2.fireEvent.focus(getByTestId("input"));
      import_react2.fireEvent.blur(getByTestId("input"));
      expect(onBlurMock).toHaveBeenCalled();
    });
  });
  describe("visibility button", () => {
    it("should toggle password visibility when click visibility button", () => {
      const { getByRole, getByTestId } = (0, import_react2.render)(
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input.Password, { label: "Input", "data-testid": "input" }) })
      );
      expect(getByTestId("input").type).toBe("password");
      import_react2.fireEvent.click(getByRole("button"));
      expect(getByTestId("input").type).toBe("text");
    });
  });
});
