var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
import { jsx, jsxs } from "react/jsx-runtime";
import React, { useRef } from "react";
import { render, fireEvent } from "@testing-library/react-native";
import * as RN from "react-native";
import { CheckedFull } from "@gympass/yoga-icons";
import { ThemeProvider, Snackbar } from "../..";
import Button from "../../Button";
RN.Animated.spring = jest.fn().mockReturnValue({
  start: jest.fn()
});
const Component = (overrideProps) => {
  const snackbarRef = useRef();
  return /* @__PURE__ */ jsxs(ThemeProvider, { children: [
    /* @__PURE__ */ jsx(
      Button,
      {
        full: true,
        small: true,
        onPress: () => {
          snackbarRef.current.open();
        },
        children: "Tap to open snackbar"
      }
    ),
    /* @__PURE__ */ jsx(
      Snackbar,
      __spreadValues({
        ref: snackbarRef,
        message: "Feedback Message"
      }, overrideProps)
    )
  ] });
};
describe("<Snackbar />", () => {
  it("should match snapshot when snackbar is default", () => {
    const { toJSON } = render(/* @__PURE__ */ jsx(Component, {}));
    expect(toJSON()).toMatchSnapshot();
  });
  it("should render with custom dataTestId", () => {
    const { getByTestId } = render(/* @__PURE__ */ jsx(Component, { dataTestId: "custom-snackbar" }));
    fireEvent.press(getByTestId("custom-snackbar"));
    expect(getByTestId("custom-snackbar")).toBeTruthy();
  });
  it("should match snapshot when have an icon and action", () => {
    const overrideProps = {
      icon: CheckedFull,
      actionLabel: "Action",
      onAction: () => {
      }
    };
    const { toJSON } = render(/* @__PURE__ */ jsx(Component, __spreadValues({}, overrideProps)));
    expect(toJSON()).toMatchSnapshot();
  });
  it("should match snapshot when have a long text", () => {
    const overrideProps = {
      message: "Lorem Ipsum is simply dummy text of the printing and types.",
      icon: CheckedFull,
      actionLabel: "Action",
      onAction: () => {
      }
    };
    const { toJSON } = render(/* @__PURE__ */ jsx(Component, __spreadValues({}, overrideProps)));
    expect(toJSON()).toMatchSnapshot();
  });
  it("should match snapshot when have a variant informative or attention prop", () => {
    const overrideProps = {
      variant: "informative"
    };
    const { toJSON } = render(/* @__PURE__ */ jsx(Component, __spreadValues({}, overrideProps)));
    expect(toJSON()).toMatchSnapshot();
  });
  it("should show and hide snackbar when the open and close Animation function is called", () => {
    const overrideProps = {
      onSnackbarClose: jest.fn(),
      actionLabel: "Action",
      onAction: jest.fn()
    };
    const { getByText, getByTestId } = render(/* @__PURE__ */ jsx(Component, __spreadValues({}, overrideProps)));
    fireEvent(getByTestId("wrapper"), "layout", {
      nativeEvent: {
        layout: { height: 200 }
      }
    });
    fireEvent.press(getByText("Tap to open snackbar"));
    expect(RN.Animated.spring.mock.calls[0][1]).toEqual({
      toValue: 0,
      bounciness: 0,
      useNativeDriver: true
    });
    fireEvent.press(getByText("Action"));
    expect(RN.Animated.spring.mock.calls[1][1]).toEqual({
      toValue: 200,
      bounciness: 0,
      useNativeDriver: true
    });
  });
});
