feat: add extensive test suite

This commit is contained in:
2026-08-30 11:33:53 +07:00 Unverified
parent 061cce00dc
commit 8359c7272e
131 changed files with 8717 additions and 2200 deletions
+23
View File
@@ -0,0 +1,23 @@
import { describe, expect, mock, test } from "bun:test";
import { createAuthHandlers } from "./handler";
describe("auth route factory", () => {
test("creates both handlers from the provided auth instance", async () => {
const auth = { name: "auth" };
const get = mock(async (_request: Request) => new Response("GET"));
const post = mock(async (_request: Request) => new Response("POST"));
const adapter = mock((_auth: typeof auth) => ({ GET: get, POST: post }));
const handlers = createAuthHandlers(adapter, auth);
expect(adapter).toHaveBeenCalledWith(auth);
expect(
await (await handlers.GET(new Request("https://buzz.test"))).text(),
).toBe("GET");
expect(
await (
await handlers.POST(
new Request("https://buzz.test", { method: "POST" }),
)
).text(),
).toBe("POST");
});
});