forked from syntaxbullet/AuroraBot-discord
feat(web): implement web server foundation
This commit is contained in:
27
src/web/router.test.ts
Normal file
27
src/web/router.test.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { router } from "./router";
|
||||
|
||||
describe("Web Router", () => {
|
||||
it("should return home page on /", async () => {
|
||||
const req = new Request("http://localhost/");
|
||||
const res = await router(req);
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.headers.get("Content-Type")).toBe("text/html");
|
||||
expect(await res.text()).toContain("Aurora Web");
|
||||
});
|
||||
|
||||
it("should return health check on /health", async () => {
|
||||
const req = new Request("http://localhost/health");
|
||||
const res = await router(req);
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.headers.get("Content-Type")).toBe("application/json");
|
||||
const data = await res.json();
|
||||
expect(data).toHaveProperty("status", "ok");
|
||||
});
|
||||
|
||||
it("should return 404 for unknown routes", async () => {
|
||||
const req = new Request("http://localhost/unknown");
|
||||
const res = await router(req);
|
||||
expect(res.status).toBe(404);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user