// @vitest-environment jsdom
import { render, screen, waitFor } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
vi.mock("@headlessui/react", async () => {
const React = await import("react");
const { Fragment } = React;
function Transition({ as: As = Fragment, children }) {
if (As === Fragment) return <>{children}>;
return {children};
}
function Disclosure({ defaultOpen = true, children }) {
const content = typeof children === "function" ? children({ open: defaultOpen }) : children;
return
{content}
;
}
function DisclosureButton(props) {
return ;
}
const DisclosurePanel = React.forwardRef(function DisclosurePanel(props, ref) {
// HeadlessUI uses a boolean `static` prop; avoid forwarding it to the DOM.
const { static: _static, ...rest } = props;
return ;
});
Disclosure.Button = DisclosureButton;
Disclosure.Panel = DisclosurePanel;
return { Disclosure, Transition };
});
vi.mock("components/bookmarks/list", () => ({
default: function BookmarksListMock({ bookmarks }) {
return count:{bookmarks?.length ?? 0}
;
},
}));
vi.mock("components/errorboundry", () => ({
default: function ErrorBoundaryMock({ children }) {
return <>{children}>;
},
}));
vi.mock("components/resolvedicon", () => ({
default: function ResolvedIconMock() {
return ;
},
}));
import BookmarksGroup from "./group";
describe("components/bookmarks/group", () => {
it("renders the group header and list", () => {
render(
,
);
expect(screen.getByText("Bookmarks")).toBeInTheDocument();
expect(screen.getByTestId("resolved-icon")).toBeInTheDocument();
expect(screen.getByTestId("bookmarks-list")).toHaveTextContent("count:1");
});
it("sets the panel height to 0 when initially collapsed", async () => {
render(
,
);
const panel = screen.getByTestId("disclosure-panel");
await waitFor(() => {
expect(panel.style.height).toBe("0px");
});
});
});