"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_yoga_icons = require("@gympass/yoga-icons");
var import__ = require("../..");
describe("<Banner />", () => {
  it("should match snapshot", () => {
    const { container } = (0, import_react2.render)(
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Banner, { message: "Feedback message." }) })
    );
    expect(container).toMatchSnapshot();
  });
  it("should match snapshot with custom variant", () => {
    const { container } = (0, import_react2.render)(
      /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import__.ThemeProvider, { children: [
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Banner, { variant: "success", message: "Success banner without button" }),
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
          import__.Banner,
          {
            variant: "informative",
            message: "Informative banner without button"
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Banner, { variant: "attention", message: "Attention banner without button" })
      ] })
    );
    expect(container).toMatchSnapshot();
  });
  it("should match snapshot with icon", () => {
    const { container } = (0, import_react2.render)(
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Banner, { icon: import_yoga_icons.CheckedFull, message: "Banner with icon" }) })
    );
    expect(container).toMatchSnapshot();
  });
  it("should match snapshot with button", () => {
    const { container } = (0, import_react2.render)(
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
        import__.Banner,
        {
          message: "Banner with button",
          primaryButton: {
            label: "Action",
            action: () => {
            }
          }
        }
      ) })
    );
    expect(container).toMatchSnapshot();
  });
  it("should call button action function when the banner button is clicked", () => {
    const onButtonClickMock = jest.fn();
    const { getByRole } = (0, import_react2.render)(
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
        import__.Banner,
        {
          message: "Banner with button",
          primaryButton: {
            label: "Action",
            action: onButtonClickMock
          }
        }
      ) })
    );
    import_react2.fireEvent.click(getByRole("button", { name: "Action" }));
    expect(onButtonClickMock).toHaveBeenCalled();
  });
  it("should match snapshot with two action buttons", () => {
    const { container } = (0, import_react2.render)(
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
        import__.Banner,
        {
          message: "Banner with two action buttons",
          primaryButton: {
            label: "Primary Action",
            action: () => {
            }
          },
          secondaryButton: {
            label: "Secondary Action",
            action: () => {
            }
          }
        }
      ) })
    );
    expect(container).toMatchSnapshot();
  });
  it("should call both buttons action function when each banner action button are clicked", () => {
    const onPrimaryButtonClickMock = jest.fn();
    const onSecondaryButtonClickMock = jest.fn();
    const { getByRole } = (0, import_react2.render)(
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
        import__.Banner,
        {
          message: "Banner with button",
          primaryButton: {
            label: "Primary Action",
            action: onPrimaryButtonClickMock
          },
          secondaryButton: {
            label: "Secondary Action",
            action: onSecondaryButtonClickMock
          }
        }
      ) })
    );
    import_react2.fireEvent.click(getByRole("button", { name: "Primary Action" }));
    expect(onPrimaryButtonClickMock).toHaveBeenCalled();
    import_react2.fireEvent.click(getByRole("button", { name: "Secondary Action" }));
    expect(onSecondaryButtonClickMock).toHaveBeenCalled();
  });
});
