import { jsx } from "react/jsx-runtime";
import React from "react";
import { render, fireEvent } from "@testing-library/react-native";
import { Booking } from "@gympass/yoga-icons";
import ThemeProvider, { v3theme } from "../../Theme";
import Button from "..";
describe("<Button />", () => {
  describe("Snapshots", () => {
    describe("primary buttons", () => {
      describe("with v3theme", () => {
        it("should match snapshot with v3theme Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { theme: v3theme, children: /* @__PURE__ */ jsx(Button, {}) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
      });
      describe("Without props", () => {
        it("should match snapshot with default Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, {}) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, {}) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with link Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Link, {}) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with default Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { icon: Booking }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { icon: Booking }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
      });
      describe("With inverted prop", () => {
        it("should match snapshot with default Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { inverted: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { inverted: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with default Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { inverted: true, icon: Booking }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { inverted: true, icon: Booking }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with icon Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Icon, { icon: Booking, inverted: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
      });
      describe("With small prop", () => {
        it("should match snapshot with default Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { small: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { small: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with default Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { small: true, icon: Booking }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { small: true, icon: Booking }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
      });
      describe("With full prop", () => {
        it("should match snapshot with default Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { full: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { full: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with default Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { full: true, icon: Booking }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { full: true, icon: Booking }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
      });
      describe("With large prop", () => {
        it("should match snapshot icon Button with large prop", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Icon, { icon: Booking, large: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
      });
    });
    describe("secondary buttons", () => {
      describe("Without props", () => {
        it("should match snapshot with default Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with link Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Link, { secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with outline Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Outline, { secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with default Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { icon: Booking, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { icon: Booking, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with icon Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Icon, { icon: Booking, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
      });
      describe("With inverted prop", () => {
        it("should match snapshot with default Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { inverted: true, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { inverted: true, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with outline Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Outline, { inverted: true, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with default Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { inverted: true, icon: Booking, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { inverted: true, icon: Booking, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with icon Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Icon, { inverted: true, icon: Booking, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
      });
      describe("With small prop", () => {
        it("should match snapshot with default Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { small: true, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { small: true, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with outline Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Outline, { small: true, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with default Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { small: true, icon: Booking, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { small: true, icon: Booking, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
      });
      describe("With full prop", () => {
        it("should match snapshot with default Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { full: true, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { full: true, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with outline Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Outline, { full: true, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with default Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { full: true, icon: Booking, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { full: true, icon: Booking, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
      });
      describe("With large prop", () => {
        it("should match snapshot icon Button with large prop", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Icon, { large: true, icon: Booking, secondary: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
      });
    });
    describe("disabled buttons", () => {
      describe("With disabled prop", () => {
        it("should match snapshot with default Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { disabled: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { disabled: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with link Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Link, { disabled: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with outline Button", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Outline, { disabled: true }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with default Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { disabled: true, icon: Booking }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with text Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { disabled: true, icon: Booking }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
        it("should match snapshot with icon Button with Icon", () => {
          const { toJSON } = render(
            /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Icon, { disabled: true, icon: Booking }) })
          );
          expect(toJSON()).toMatchSnapshot();
        });
      });
    });
  });
  describe("onPress prop", () => {
    it("should call onPress function when click on Button", () => {
      const onPressMock = jest.fn();
      const { getByText } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { onPress: onPressMock, children: "Button" }) })
      );
      fireEvent.press(getByText("Button"));
      expect(onPressMock).toHaveBeenCalled();
    });
    it("should call onPress function when press on Button.Text", () => {
      const onPressMock = jest.fn();
      const { getByText } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Text, { onPress: onPressMock, children: "Button.Text" }) })
      );
      fireEvent.press(getByText("Button.Text"));
      expect(onPressMock).toHaveBeenCalled();
    });
    it("should call onPress function when press on Button.Icon", () => {
      const onPressMock = jest.fn();
      const { getByRole } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Icon, { onPress: onPressMock, icon: Booking }) })
      );
      fireEvent.press(getByRole("button"));
      expect(onPressMock).toHaveBeenCalled();
    });
    it("should call onPress function when press on Button.Outline", () => {
      const onPressMock = jest.fn();
      const { getByRole } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button.Outline, { onPress: onPressMock }) })
      );
      fireEvent.press(getByRole("button"));
      expect(onPressMock).toHaveBeenCalled();
    });
    it("should not call onPress function when press on Button disabled", () => {
      const onPressMock = jest.fn();
      const { getByText } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Button, { disabled: true, onPress: onPressMock, children: "Button" }) })
      );
      fireEvent.press(getByText("Button"));
      expect(onPressMock).not.toHaveBeenCalled();
    });
  });
});
