// packages/core/tests/components/pagination/pagination.test.tsx import { fireEvent, render, screen } from "@solidjs/testing-library"; import { describe, expect, it, vi } from "vitest"; import { Pagination } from "../../../src/components/pagination/index"; describe("Pagination – navigation and buttons", () => { it("renders with role=navigation", () => { render(() => ( {}}> )); expect(screen.getByRole("navigation")).toBeTruthy(); }); it("previous button is disabled on first page", () => { render(() => ( {}}> )); expect(screen.getByRole("button")).toBeDisabled(); }); it("next button is disabled on last page", () => { render(() => ( {}}> )); expect(screen.getByRole("button")).toBeDisabled(); }); }); describe("Pagination – page change callbacks", () => { it("clicking previous calls onPageChange with page-1", () => { const onChange = vi.fn(); render(() => ( )); fireEvent.click(screen.getByRole("button")); expect(onChange).toHaveBeenCalledWith(2); }); it("clicking next calls onPageChange with page+1", () => { const onChange = vi.fn(); render(() => ( )); fireEvent.click(screen.getByRole("button")); expect(onChange).toHaveBeenCalledWith(4); }); it("Items renders page buttons via render prop", () => { render(() => ( {}}> {(item) => item.type === "page" ? ( ) : ( ) } )); const buttons = screen.getAllByRole("button"); const activePage = buttons.find((b) => b.getAttribute("aria-current") === "page"); expect(activePage?.textContent).toBe("2"); }); });