var __getOwnPropNames = Object.getOwnPropertyNames;
var __commonJS = (cb, mod) => function __require() {
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __async = (__this, __arguments, generator) => {
  return new Promise((resolve, reject) => {
    var fulfilled = (value) => {
      try {
        step(generator.next(value));
      } catch (e) {
        reject(e);
      }
    };
    var rejected = (value) => {
      try {
        step(generator.throw(value));
      } catch (e) {
        reject(e);
      }
    };
    var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
    step((generator = generator.apply(__this, __arguments)).next());
  });
};
import { jsx } from "react/jsx-runtime";
import React from "react";
import { fireEvent, render, screen } from "@testing-library/react";
import { ThemeProvider, Snackbar } from "../..";
var require_Snackbar_test = __commonJS({
  "src/Snackbar/web/Snackbar.test.jsx"(exports) {
    describe("<Snackbar />", () => {
      jest.useRealTimers();
      it("should match snapshot", () => {
        const { container } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Snackbar, { open: true, message: "Make wellbeing universal", onClose: jest.fn() }) })
        );
        expect(container).toMatchSnapshot();
      });
      it("should render with custom dataTestId", () => {
        render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
            Snackbar,
            {
              open: true,
              message: "Make wellbeing universal",
              onClose: jest.fn(),
              dataTestId: "custom-snackbar"
            }
          ) })
        );
        expect(screen.getByTestId("custom-snackbar")).toBeInTheDocument();
      });
      it("should render a minimal snackbar", () => {
        render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Snackbar, { open: true, message: "Make wellbeing universal", onClose: jest.fn() }) })
        );
        screen.getByRole("alert");
        screen.getByTestId("img");
        screen.getByLabelText("success");
        screen.getByText("Make wellbeing universal");
      });
      it("should not render an icon", () => {
        render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
            Snackbar,
            {
              open: true,
              message: "Make wellbeing universal",
              onClose: jest.fn(),
              hideIcon: true
            }
          ) })
        );
        expect(screen.queryByRole("img")).toBeNull();
      });
      it("should render a custom action button", () => {
        const onActionMock = jest.fn();
        render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
            Snackbar,
            {
              open: true,
              message: "Make wellbeing universal",
              onAction: onActionMock,
              onClose: jest.fn(),
              actionLabel: "Let's go"
            }
          ) })
        );
        const button = screen.getByRole("button", { name: /let's go/i });
        fireEvent.click(button);
        expect(onActionMock).toHaveBeenCalledTimes(1);
      });
      it("should render a close button", () => {
        const onCloseMock = jest.fn();
        render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
            Snackbar,
            {
              open: true,
              message: "Make wellbeing universal",
              onClose: onCloseMock
            }
          ) })
        );
        const button = screen.getByRole("button");
        fireEvent.click(button);
        expect(onCloseMock).toHaveBeenCalledTimes(1);
      });
      it("should close after timeout", () => __async(exports, null, function* () {
        jest.useFakeTimers();
        const onCloseMock = jest.fn();
        render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
            Snackbar,
            {
              open: true,
              duration: 1e3,
              message: "Make wellbeing universal",
              onClose: onCloseMock,
              hideCloseButton: true
            }
          ) })
        );
        expect(screen.queryByRole("button")).toBeNull();
        jest.runAllTimers();
        expect(onCloseMock).toHaveBeenCalledTimes(1);
      }));
      it("should close with timeout set up", () => __async(exports, null, function* () {
        const onCloseMock = jest.fn();
        render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
            Snackbar,
            {
              open: true,
              duration: 1e3,
              message: "Make wellbeing universal",
              onClose: onCloseMock
            }
          ) })
        );
        const button = screen.getByRole("button");
        fireEvent.click(button);
        expect(onCloseMock).toHaveBeenCalledTimes(1);
      }));
    });
  }
});
export default require_Snackbar_test();
