deno.land / x / alosaur@v1.1.1 / e2e / default.test.ts

default.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
50
51
52
import { assertEquals } from "../src/deps_test.ts";import { killServer, startServer } from "./test.utils.ts";const { test } = Deno;
/** * Test cases */test({ name: "[http] default server should response 200, 404", async fn(): Promise<void> { const process = await startServer("./examples/default/app.ts"); const baseUrl = "http://localhost:8000";
try { const r1 = await fetch(baseUrl + "/home/query-name"); const r2 = await fetch(baseUrl + "/home/query-name/"); const r3 = await fetch(baseUrl + "/"); const text_r1 = await r1.text(); const text_r2 = await r2.text(); const text_r3 = await r3.text();
assertEquals(r1.status, 200); assertEquals(r2.status, 404); assertEquals(r3.status, 200);
assertEquals(text_r1, "Hey! undefined"); assertEquals(text_r2, "Not found"); assertEquals(text_r3, "Hello world"); } finally { killServer(process); } },});
test({ name: "[http] default server should response with query", async fn(): Promise<void> { const process = await startServer("./examples/default/app.ts"); const baseUrl = "http://localhost:8000";
try { const response = await fetch(baseUrl + "/home/query-name?name=john"); const text = await response.text();
assertEquals(response.status, 200); assertEquals(text, "Hey! john"); } finally { killServer(process); } },});
alosaur

Version Info

Tagged at
2 months ago