"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
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;
};
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_react_native = require("@testing-library/react-native");
var RN = __toESM(require("react-native"));
var import_yoga_icons = require("@gympass/yoga-icons");
var import__ = require("../..");
var import_Button = __toESM(require("../../Button"));
RN.Animated.spring = jest.fn().mockReturnValue({
  start: jest.fn()
});
const Component = (overrideProps) => {
  const snackbarRef = (0, import_react.useRef)();
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import__.ThemeProvider, { children: [
    /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
      import_Button.default,
      {
        full: true,
        small: true,
        onPress: () => {
          snackbarRef.current.open();
        },
        children: "Tap to open snackbar"
      }
    ),
    /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
      import__.Snackbar,
      __spreadValues({
        ref: snackbarRef,
        message: "Feedback Message"
      }, overrideProps)
    )
  ] });
};
describe("<Snackbar />", () => {
  it("should match snapshot when snackbar is default", () => {
    const { toJSON } = (0, import_react_native.render)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}));
    expect(toJSON()).toMatchSnapshot();
  });
  it("should render with custom dataTestId", () => {
    const { getByTestId } = (0, import_react_native.render)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { dataTestId: "custom-snackbar" }));
    import_react_native.fireEvent.press(getByTestId("custom-snackbar"));
    expect(getByTestId("custom-snackbar")).toBeTruthy();
  });
  it("should match snapshot when have an icon and action", () => {
    const overrideProps = {
      icon: import_yoga_icons.CheckedFull,
      actionLabel: "Action",
      onAction: () => {
      }
    };
    const { toJSON } = (0, import_react_native.render)(/* @__PURE__ */ (0, import_jsx_runtime.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: import_yoga_icons.CheckedFull,
      actionLabel: "Action",
      onAction: () => {
      }
    };
    const { toJSON } = (0, import_react_native.render)(/* @__PURE__ */ (0, import_jsx_runtime.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 } = (0, import_react_native.render)(/* @__PURE__ */ (0, import_jsx_runtime.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 } = (0, import_react_native.render)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, __spreadValues({}, overrideProps)));
    (0, import_react_native.fireEvent)(getByTestId("wrapper"), "layout", {
      nativeEvent: {
        layout: { height: 200 }
      }
    });
    import_react_native.fireEvent.press(getByText("Tap to open snackbar"));
    expect(RN.Animated.spring.mock.calls[0][1]).toEqual({
      toValue: 0,
      bounciness: 0,
      useNativeDriver: true
    });
    import_react_native.fireEvent.press(getByText("Action"));
    expect(RN.Animated.spring.mock.calls[1][1]).toEqual({
      toValue: 200,
      bounciness: 0,
      useNativeDriver: true
    });
  });
});
