-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
custom_url_search_params_test.ts
62 lines (51 loc) · 1.15 KB
/
custom_url_search_params_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
53
54
55
56
57
58
59
60
61
62
import { assertEquals } from "@std/assert";
import { CustomURLSearchParams } from "./custom_url_search_params.ts";
const url = "https://test.com/api?text=hello&speed=100&flg=true&ng=false";
const { searchParams } = new URL(url);
const customSearchParams = new CustomURLSearchParams(searchParams);
Deno.test("getString", () => {
assertEquals(
customSearchParams.getString("text"),
"hello",
);
assertEquals(
customSearchParams.getString("message"),
"",
);
assertEquals(
customSearchParams.getString("message", "default"),
"default",
);
});
Deno.test("getNumber", () => {
assertEquals(
customSearchParams.getNumber("speed"),
100,
);
assertEquals(
customSearchParams.getNumber("velocity"),
0,
);
assertEquals(
customSearchParams.getNumber("velocity", 10),
10,
);
});
Deno.test("getBoolean", () => {
assertEquals(
customSearchParams.getBoolean("flg"),
true,
);
assertEquals(
customSearchParams.getBoolean("ok"),
false,
);
assertEquals(
customSearchParams.getBoolean("ng"),
false,
);
assertEquals(
customSearchParams.getBoolean("ok", true),
true,
);
});