generated from kawarimidoll/deno-dev-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_test.ts
116 lines (107 loc) · 2.22 KB
/
main_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { assert, assertEquals } from "./dev_deps.ts";
import { parseCliArgs } from "./main.ts";
Deno.test("[parseCliArgs] pattern 1", () => {
const {
args,
clear,
debug,
help,
quiet,
version,
watch,
runOptions,
} = parseCliArgs([
"--allow-all",
"-q",
"main.ts",
"--script-flag",
"script-arg",
]);
assertEquals(args, ["main.ts", "--script-flag", "script-arg"]);
assert([clear, debug, help, version].every((flag) => flag === false));
assert(quiet);
assertEquals(watch, []);
assertEquals(runOptions, [
"--allow-all",
"--no-check",
"--unstable",
"--watch",
"--quiet",
]);
});
Deno.test("[parseCliArgs] pattern 2", () => {
const {
args,
clear,
debug,
help,
quiet,
version,
watch,
runOptions,
} = parseCliArgs([
"--watch=a.txt,b.txt",
"--no-check",
"--unstable",
"--compat",
"--clear",
"main.ts",
]);
assertEquals(args, ["main.ts"]);
assert([debug, help, quiet, version].every((flag) => flag === false));
assert(clear);
assertEquals(watch, ["a.txt", "b.txt"]);
assertEquals(runOptions, [
"--allow-all",
"--no-check",
"--unstable",
"--watch",
"--compat",
]);
});
Deno.test("[parseCliArgs] pattern 3", () => {
const {
args,
clear,
debug,
help,
quiet,
version,
watch,
runOptions,
} = parseCliArgs([
"-Aqfc",
"deno.json",
"main.ts",
]);
assertEquals(args, ["main.ts"]);
assert([clear, debug, help, version].every((flag) => flag === false));
assert(quiet);
assertEquals(watch, []);
assertEquals(runOptions, [
"--allow-all",
"--no-check",
"--unstable",
"--watch",
"-f",
"-c=deno.json",
"--quiet",
]);
});
Deno.test("[parseCliArgs] pattern 4", () => {
const { args, runOptions } = parseCliArgs(["--shuffle", "test.ts"]);
assertEquals(args, ["test.ts"]);
assertEquals(runOptions, [
"--allow-all",
"--no-check",
"--unstable",
"--watch",
"--shuffle",
]);
});
Deno.test("[parseCliArgs] pattern 5", () => {
assert(parseCliArgs(["--help"]).help);
assert(parseCliArgs(["-h"]).help);
assert(parseCliArgs(["--version"]).version);
assert(parseCliArgs(["-v"]).version);
});