-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.ts
More file actions
28 lines (24 loc) · 862 Bytes
/
main_test.ts
File metadata and controls
28 lines (24 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { assertEquals, assertStringIncludes } from "@std/assert";
import { Application, Router } from "jsr:@oak/oak";
import { getHomePage } from "./ui/pages.ts";
// Create a simplified version of the router for testing
const createTestRouter = () => {
const router = new Router();
router.get("/", async (ctx) => {
ctx.response.body = await getHomePage();
});
return router;
};
Deno.test("Home route renders correctly", async () => {
const router = createTestRouter();
const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());
const resp = (await app.handle(
new Request("http://localhost:8080/"),
)) as Response;
assertEquals(resp.status, 200);
const text = await resp.text();
assertStringIncludes(text, "QV - Quadratic Voting for Slack");
assertStringIncludes(text, "Add to Slack");
});