import { cleanup, fireEvent, render, screen } from "@testing-library/react"; import { afterEach, describe, expect, it, vi } from "vitest"; import { IntegrationCursorPagination } from "./integration-cursor-pagination"; afterEach(cleanup); describe("IntegrationCursorPagination", () => { it("provides stable previous and next controls without inventing a total", () => { const onPrevious = vi.fn(); const onNext = vi.fn(); render( , ); expect(screen.getByText("Page 2 ยท 25 results")).toBeTruthy(); fireEvent.click(screen.getByLabelText("Go to previous page")); fireEvent.click(screen.getByLabelText("Go to next page")); expect(onPrevious).toHaveBeenCalledOnce(); expect(onNext).toHaveBeenCalledOnce(); }); it("hides when the first cursor page has no continuation", () => { const { container } = render( undefined} onNext={() => undefined} />, ); expect(container.innerHTML).toBe(""); }); });