All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 50s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
16 lines
690 B
TypeScript
16 lines
690 B
TypeScript
import "../setup.ts";
|
|
import { assertEquals } from "@std/assert";
|
|
import { parsePagination } from "../../lib/pagination.ts";
|
|
|
|
Deno.test("parsePagination: defaults, bounds and garbage", () => {
|
|
const p = (q: string, def?: number) =>
|
|
parsePagination(new URLSearchParams(q), def);
|
|
assertEquals(p(""), { page: 1, limit: 20 });
|
|
assertEquals(p("page=3&limit=5"), { page: 3, limit: 5 });
|
|
assertEquals(p("page=0&limit=0"), { page: 1, limit: 20 });
|
|
assertEquals(p("page=-4&limit=-1"), { page: 1, limit: 1 });
|
|
assertEquals(p("limit=1000"), { page: 1, limit: 100 });
|
|
assertEquals(p("page=abc&limit=xyz"), { page: 1, limit: 20 });
|
|
assertEquals(p("", 7), { page: 1, limit: 7 });
|
|
});
|