-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
query_test.ts
41 lines (37 loc) · 998 Bytes
/
query_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
import { Fastro } from "../mod.ts";
import { assertEquals } from "../deps.ts";
const { test } = Deno;
const port = 3004;
const base = `http://localhost:${port}`;
const server = new Fastro();
Deno.env.set("DENO_ENV", "test");
test({
name: "URL QUERY",
async fn() {
server.listen({ port });
const result = await fetch(
`${base}/hello/v1/queryall?name=pram&address=cirebon`,
);
const txt = await result.text();
const query = JSON.parse(txt);
assertEquals(query, { "name": "pram", "address": "cirebon" });
server.close();
},
sanitizeResources: false,
sanitizeOps: false,
});
test({
name: "URL QUERY BY NAME",
async fn() {
server.listen({ port });
const result = await fetch(
`${base}/hello/v1/querybyname?name=pram&address=cirebon`,
);
const txt = await result.text();
const query = JSON.parse(txt);
assertEquals(query, { "name": "pram" });
server.close();
},
sanitizeResources: false,
sanitizeOps: false,
});