import { jsx, jsxs } from "react/jsx-runtime";
import React from "react";
import { screen, render, fireEvent, cleanup } from "@testing-library/react";
import { ThemeProvider, Button } from "../..";
import BottomSheet from ".";
describe("<BottomSheet />", () => {
  afterEach(cleanup);
  it("should match snapshot", () => {
    const { baseElement } = render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsxs(BottomSheet, { isOpen: true, children: [
        /* @__PURE__ */ jsx(BottomSheet.Header, { children: "Title" }),
        /* @__PURE__ */ jsx(BottomSheet.Content, { children: "Subtitle" }),
        /* @__PURE__ */ jsx(BottomSheet.Footer, { children: /* @__PURE__ */ jsx(Button, { secondary: true, children: "Ok, got it" }) })
      ] }) })
    );
    expect(baseElement).toMatchSnapshot();
  });
  it("should render a minimal bottom sheet", () => {
    const onActionMock = jest.fn();
    render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsxs(BottomSheet, { isOpen: true, children: [
        /* @__PURE__ */ jsx(BottomSheet.Header, { children: "Title" }),
        /* @__PURE__ */ jsx(BottomSheet.Content, { children: "Subtitle" }),
        /* @__PURE__ */ jsx(BottomSheet.Footer, { children: /* @__PURE__ */ jsx(Button, { onClick: onActionMock, secondary: true, children: "Ok, got it" }) })
      ] }) })
    );
    screen.getByText("Title");
    screen.getByText("Subtitle");
    const button = screen.getByRole("button", { name: /Ok, got it/i });
    fireEvent.click(button);
    expect(onActionMock).toHaveBeenCalledTimes(1);
  });
  it("should hide the close button", () => {
    render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(BottomSheet, { isOpen: true, onClose: () => {
      }, children: /* @__PURE__ */ jsx(BottomSheet.Header, { children: "Title" }) }) })
    );
    expect(screen.queryByRole("button")).toBeNull();
  });
  it("should show the close button", () => {
    render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(BottomSheet, { isOpen: true, hideCloseButton: false, onClose: () => {
      }, children: /* @__PURE__ */ jsx(BottomSheet.Header, { children: "Title" }) }) })
    );
    expect(screen.getByRole("button")).not.toBeNull();
  });
});
