feat: centralize application framework primitives
This commit is contained in:
1 parent
96e082b943
commit
a3ddd39b7b
73 files changed
+1429
-84
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { createContext } from "../src/index.ts";
|
||||
|
||||
test("context pagination applies defaults, bounds and cursor parsing", () => {
|
||||
const request = new Request("https://example.test/items?limit=500&cursor=next-1");
|
||||
const ctx = createContext(request, new URL(request.url));
|
||||
expect(ctx.pagination({ defaultLimit: 25, maxLimit: 100 })).toEqual({
|
||||
limit: 100,
|
||||
cursor: "next-1",
|
||||
});
|
||||
});
|
||||
|
||||
test("context pagination rejects invalid limits", () => {
|
||||
const request = new Request("https://example.test/items?limit=-2");
|
||||
const ctx = createContext(request, new URL(request.url));
|
||||
expect(ctx.pagination()).toEqual({ limit: 25, cursor: undefined });
|
||||
});
|
||||
Reference in new issue
Block a user