-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
spa.test.ts
44 lines (33 loc) · 975 Bytes
/
spa.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
import { assertEquals } from "../src/deps_test.ts";
import { itLog, killServer, startServer } from "./test.utils.ts";
const { test } = Deno;
/**
* Test cases
*/
test({
name: "[http] spa server, requests to info controller",
async fn(): Promise<void> {
const process = await startServer("./examples/spa/app.ts");
const baseUrl = "http://localhost:8000";
itLog("/", true);
try {
// It
itLog("\t ''");
let response = await fetch(baseUrl);
let text = await response.text();
assertEquals(response.status, 404);
// It
itLog("\t '/www'");
response = await fetch(baseUrl + "/www");
text = await response.text();
assertEquals(response.status, 200);
// It
itLog("\t '/www/spa-route'");
response = await fetch(baseUrl + "/www/spa-route");
text = await response.text();
assertEquals(response.status, 200);
} finally {
killServer(process);
}
},
});