import { describe, it, expect, beforeEach } from "vitest"; import { initPageJump } from "../scripts/init-page-jump.mjs"; function mountPagination(totalPages = 8, current = 1) { document.body.innerHTML = `
`; } describe("page jump binder", () => { beforeEach(() => { document.body.innerHTML = ""; window.location.hash = ""; }); it("clicking Go updates hash to input value (clamped)", () => { mountPagination(8, 1); initPageJump(); const input = document.querySelector(".jump-input"); const btn = document.querySelector(".jump-btn"); input.value = "5"; btn.click(); expect(window.location.hash.includes("page=5")).toBe(true); }); it("clamps values below min to 1", () => { mountPagination(8, 1); initPageJump(); const input = document.querySelector(".jump-input"); const btn = document.querySelector(".jump-btn"); input.value = "0"; btn.click(); expect(window.location.hash.includes("page=1")).toBe(true); }); });