import { jsx, jsxs } from "react/jsx-runtime";
import React from "react";
import { render, fireEvent } from "@testing-library/react-native";
import { CheckedFull } from "@gympass/yoga-icons";
import { ThemeProvider, Banner } from "../..";
describe("<Banner />", () => {
  it("should match snapshot", () => {
    const { toJSON } = render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Banner, { message: "Feedback message." }) })
    );
    expect(toJSON()).toMatchSnapshot();
  });
  it("should match snapshot with custom variant", () => {
    const { toJSON } = render(
      /* @__PURE__ */ jsxs(ThemeProvider, { children: [
        /* @__PURE__ */ jsx(Banner, { variant: "success", message: "Success banner without button" }),
        /* @__PURE__ */ jsx(
          Banner,
          {
            variant: "informative",
            message: "Informative banner without button"
          }
        ),
        /* @__PURE__ */ jsx(Banner, { variant: "attention", message: "Attention banner without button" })
      ] })
    );
    expect(toJSON()).toMatchSnapshot();
  });
  it("should match snapshot with icon", () => {
    const { toJSON } = render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Banner, { icon: CheckedFull, message: "Banner with icon" }) })
    );
    expect(toJSON()).toMatchSnapshot();
  });
  it("should match snapshot with button", () => {
    const { toJSON } = render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
        Banner,
        {
          message: "Banner with button",
          primaryButton: {
            label: "Action",
            action: () => {
            }
          }
        }
      ) })
    );
    expect(toJSON()).toMatchSnapshot();
  });
  it("should call button action function when the banner button is pressed", () => {
    const onButtonPressMock = jest.fn();
    const { getByText } = render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
        Banner,
        {
          message: "Banner with button",
          primaryButton: {
            label: "Action",
            action: onButtonPressMock
          }
        }
      ) })
    );
    fireEvent.press(getByText("Action"));
    expect(onButtonPressMock).toHaveBeenCalled();
  });
  it("should match snapshot with two action buttons", () => {
    const { toJSON } = render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
        Banner,
        {
          message: "Banner with two action buttons",
          primaryButton: {
            label: "Primary Action",
            action: () => {
            }
          },
          secondaryButton: {
            label: "Secondary Action",
            action: () => {
            }
          }
        }
      ) })
    );
    expect(toJSON()).toMatchSnapshot();
  });
  it("should call both buttons action function when each banner action button are pressed", () => {
    const onPrimaryButtonPressMock = jest.fn();
    const onSecondaryButtonPressMock = jest.fn();
    const { getByText } = render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
        Banner,
        {
          message: "Banner with button",
          primaryButton: {
            label: "Primary Action",
            action: onPrimaryButtonPressMock
          },
          secondaryButton: {
            label: "Secondary Action",
            action: onSecondaryButtonPressMock
          }
        }
      ) })
    );
    fireEvent.press(getByText("Primary Action"));
    expect(onPrimaryButtonPressMock).toHaveBeenCalled();
    fireEvent.press(getByText("Secondary Action"));
    expect(onSecondaryButtonPressMock).toHaveBeenCalled();
  });
});
