import { render, screen } from "@testing-library/react";
import { userEvent } from "@testing-library/user-event";
import { DrawerClose } from "./DrawerClose";
import { DrawerRoot } from "./DrawerRoot";
describe("DrawerTrigger", () => {
const customRender = (ui, contextProps) => {
return render({ui});
};
test("renders visibly into the document", () => {
render();
expect(screen.getByRole("button")).toBeVisible();
});
test("uses the sticky property to add a class", () => {
render();
// eslint-disable-next-line jest-dom/prefer-to-have-class
expect(screen.getByRole("button")).toHaveAttribute(
"class",
expect.stringContaining("sticky")
);
});
test("uses openChange handler from context", async () => {
const user = userEvent.setup();
const handleChange = jest.fn();
customRender(, {
onOpenChange: handleChange,
});
await user.click(screen.getByRole("button"));
expect(handleChange).toHaveBeenCalledWith(false);
});
});