"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("../../..");
var import__2 = __toESM(require("."));
describe("<PlanCard />", () => {
  const buttonOnClickMock = jest.fn();
  const renderPlan = ({ clickableItems } = {}) => (0, import_react2.render)(
    /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import__2.default, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default.Tag, { variant: "informative", children: "Recommended Plan" }),
      /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
        import__2.default.Content,
        {
          subtitle: "plan",
          title: "Basic",
          currency: "$",
          price: "99.90",
          period: "/month",
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default.Subtitle, { children: "Get access to" }),
            /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import__2.default.List, { children: [
              /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
                import__2.default.ListItem,
                {
                  icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
                    import__.Icon,
                    {
                      as: import_yoga_icons.MapPin,
                      height: "small",
                      width: "small",
                      stroke: "medium"
                    }
                  ),
                  text: "gyms and studios",
                  onClick: clickableItems && jest.fn()
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
                import__2.default.ListItem,
                {
                  icon: import_yoga_icons.Star,
                  text: "list item",
                  buttonProps: {
                    children: "button",
                    as: "a",
                    onClick: buttonOnClickMock
                  },
                  onClick: clickableItems && jest.fn()
                }
              )
            ] })
          ]
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default.Actions, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Button, { full: true, children: "Select this plan" }) })
    ] }) })
  );
  describe("Events", () => {
    it("should call onClick when ListItem has a button", () => {
      const { getByText } = renderPlan();
      import_react2.fireEvent.click(getByText("button"));
      expect(buttonOnClickMock).toHaveBeenCalled();
    });
    it("should make list item clickable", () => {
      const itemClickMock = jest.fn();
      const { getByRole } = (0, import_react2.render)(
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default, { variant: "energy", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default.Content, { title: "Basic", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default.List, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
          import__2.default.ListItem,
          {
            icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
              import__.Icon,
              {
                as: import_yoga_icons.MapPin,
                height: "small",
                width: "small",
                stroke: "medium"
              }
            ),
            text: "gyms and studios",
            onClick: itemClickMock
          }
        ) }) }) }) })
      );
      import_react2.fireEvent.click(getByRole("button", { label: "gyms and studios" }));
      expect(itemClickMock).toHaveBeenCalled();
    });
  });
  describe("Snapshots", () => {
    it("should match snapshot with default PlanCard", () => {
      const { container: planCard } = renderPlan();
      expect(planCard).toMatchSnapshot();
    });
    it("should match snapshot with variant", () => {
      const { container } = (0, import_react2.render)(
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default, { variant: "hope", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
          import__2.default.Content,
          {
            subtitle: "plan",
            title: "Basic",
            currency: "$",
            price: "99.90",
            period: "/month"
          }
        ) }) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should match snapshot with suffix", () => {
      const { container } = (0, import_react2.render)(
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default, { variant: "hope", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
          import__2.default.Content,
          {
            subtitle: "plan",
            title: "Basic",
            currency: "$",
            suffix: "MXN",
            price: "99.90",
            period: "/month"
          }
        ) }) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should render the extra content", () => {
      const { container } = (0, import_react2.render)(
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default.Content, { title: "Basic", extra: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Hello" }) }) }) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should render the title without a colored badge", () => {
      const { getByText } = (0, import_react2.render)(
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default.Content, { title: "Basic" }) }) })
      );
      expect(getByText("Basic")).toMatchSnapshot();
    });
    it("should render the title with a colored badge", () => {
      const { getByText } = (0, import_react2.render)(
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default.Content, { title: "Basic", badgeColor: "energy" }) }) })
      );
      expect(getByText("Basic")).toMatchSnapshot();
    });
    it("should render the discount", () => {
      const { container } = (0, import_react2.render)(
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default, { discount: "SAVE 40%", variant: "energy", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default.Content, { title: "Basic" }) }) })
      );
      expect(container).toMatchSnapshot();
    });
    it("should render list item content as button", () => {
      const { container } = renderPlan({ clickableItems: true });
      expect(container).toMatchSnapshot();
    });
  });
});
