-
Notifications
You must be signed in to change notification settings - Fork 2
/
main_test.ts
30 lines (26 loc) · 943 Bytes
/
main_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
import { assertEquals } from '@std/assert';
import server from './main.ts';
Deno.test(async function serverFetch() {
const req = new Request('https://deno.land');
const res = await server.fetch(req);
assertEquals(await res.text(), 'Home page');
});
Deno.test(async function serverFetchNotFound() {
const req = new Request('https://deno.land/404');
const res = await server.fetch(req);
assertEquals(res.status, 404);
});
Deno.test(async function serverFetchUsers() {
const req = new Request('https://deno.land/users/123');
const res = await server.fetch(req);
assertEquals(await res.text(), '123');
});
Deno.test(async function serverFetchStatic() {
const req = new Request('https://deno.land/static/hello.js');
const res = await server.fetch(req);
assertEquals(await res.text(), 'console.log("Hello, world!");\n');
assertEquals(
res.headers.get('content-type'),
'text/javascript; charset=UTF-8',
);
});