This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmod_test.ts
56 lines (51 loc) · 1.72 KB
/
mod_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
import { assert } from "./deps.ts";
const decoder = new TextDecoder();
// sets NO_COLOR so there's no color codes polluting the output.
Deno.test("logger.info()", async () => {
const p = Deno.run({
cmd: ["deno", "run", "--unstable", "./testfiles/info.ts"],
stdout: "piped",
env: {
"NO_COLOR": "",
}
});
const stdout = decoder.decode(await p.output());
p.close();
assert(/\[\d{4}\/\d{2}\/\d{2} \d{1,2}:\d{2}:\d{2} (?:AM|PM)\] \[info test\] \[INFO\] .+\n/gm.test(stdout));
})
Deno.test("logger.error()", async () => {
const p = Deno.run({
cmd: ["deno", "run", "--unstable", "./testfiles/error.ts"],
stdout: "piped",
env: {
"NO_COLOR": "",
}
});
const stdout = decoder.decode(await p.output());
p.close();
assert(/\[\d{4}\/\d{2}\/\d{2} \d{1,2}:\d{2}:\d{2} (?:AM|PM)\] \[error test\] \[ERROR\] .+\n/gm.test(stdout));
})
Deno.test("logger.debug()", async () => {
const p = Deno.run({
cmd: ["deno", "run", "--unstable", "./testfiles/debug.ts"],
stdout: "piped",
env: {
"NO_COLOR": "",
}
});
const stdout = decoder.decode(await p.output());
p.close();
assert(/\[\d{4}\/\d{2}\/\d{2} \d{1,2}:\d{2}:\d{2} (?:AM|PM)\] \[debug test\] \[DEBUG\] .+\n/gm.test(stdout));
})
Deno.test("logger.warn()", async () => {
const p = Deno.run({
cmd: ["deno", "run", "--unstable", "./testfiles/warn.ts"],
stdout: "piped",
env: {
"NO_COLOR": "",
}
});
const stdout = decoder.decode(await p.output());
p.close();
assert(/\[\d{4}\/\d{2}\/\d{2} \d{1,2}:\d{2}:\d{2} (?:AM|PM)\] \[warn test\] \[WARN\] .+\n/gm.test(stdout));
})