-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.ts
More file actions
48 lines (39 loc) · 861 Bytes
/
example_test.ts
File metadata and controls
48 lines (39 loc) · 861 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { delay } from "https://deno.land/std@0.57.0/async/delay.ts";
import {
assertEquals,
} from "https://deno.land/std@0.57.0/testing/asserts.ts";
async function runStart() {
const p = Deno.run({
cmd: [
Deno.execPath(),
"run",
"--allow-net",
"--allow-read",
"app.ts",
"start",
"--port",
"4600",
"example",
],
});
await delay(100);
return p;
}
Deno.test("example", async () => {
const p = await runStart();
// GET /
{
const res = await fetch("http://0.0.0.0:4600");
const body = await res.text();
assertEquals(body, "Hello from Serva.");
}
// POST /
{
const res = await fetch("http://0.0.0.0:4600", {
method: "POST",
});
const body = await res.text();
assertEquals(body, "Wait a minute, please Mr. POST-man.");
}
p.close();
});