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 Drawer from ".";
describe("<Drawer />", () => {
  afterEach(cleanup);
  it("should match snapshot", () => {
    const { baseElement } = render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsxs(Drawer, { isOpen: true, children: [
        /* @__PURE__ */ jsx(Drawer.Header, { children: "Title" }),
        /* @__PURE__ */ jsx(Drawer.Content, { children: "Subtitle" }),
        /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Button, { secondary: true, children: "Ok, got it" }) })
      ] }) })
    );
    expect(baseElement).toMatchSnapshot();
  });
  it("should render a minimal drawer", () => {
    const onActionMock = jest.fn();
    render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsxs(Drawer, { isOpen: true, children: [
        /* @__PURE__ */ jsx(Drawer.Header, { children: "Title" }),
        /* @__PURE__ */ jsx(Drawer.Content, { children: "Subtitle" }),
        /* @__PURE__ */ jsx(Drawer.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);
  });
});
