-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe2e_test.ts
49 lines (42 loc) · 1.25 KB
/
e2e_test.ts
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { createHandler } from "$fresh/server.ts";
import manifest from "@/fresh.gen.ts";
import {
assert,
assertEquals,
assertFalse,
assertInstanceOf,
} from "std/assert/mod.ts";
Deno.test("[http]", async (test) => {
const handler = await createHandler(manifest);
await test.step("GET /", async () => {
const response = await handler(new Request("http://localhost"));
assert(response.ok);
assertInstanceOf(response.body, ReadableStream);
assertEquals(
response.headers.get("content-type"),
"text/html; charset=utf-8",
);
assertEquals(response.status, 200);
});
await test.step("GET /account", async () => {
const response = await handler(
new Request("http://localhost/account"),
);
assertFalse(response.ok);
assertFalse(response.body);
assertEquals(
response.headers.get("location"),
"/signin?from=http://localhost/account",
);
assertEquals(response.status, 303);
});
await test.step("GET /signout", async () => {
const response = await handler(
new Request("http://localhost/signout"),
);
assertFalse(response.ok);
assertFalse(response.body);
assertEquals(response.headers.get("location"), "/");
assertEquals(response.status, 302);
});
});