-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsgr_test.ts
32 lines (31 loc) · 1.12 KB
/
sgr_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
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { parseSgr, type Sgr } from "./sgr.ts";
Deno.test("parseSgr", async (t) => {
const testcases: [string, Sgr][] = [
["", { reset: true }],
["1", { bold: true }],
["1;2;3", { bold: true, dim: true, italic: true }],
["1;31", { bold: true, foreground: 1 }],
["30;47", { foreground: 0, background: 7 }],
["90;107", { foreground: 8, background: 15 }],
["38;5;255;48;5;232", { foreground: 255, background: 232 }],
["38;5;;48;5;", { foreground: 0, background: 0 }],
["38;2;255;255;255;48;2;0;0;0", {
foreground: [255, 255, 255],
background: [0, 0, 0],
}],
["38;2;;;;48;2;;;", {
foreground: [0, 0, 0],
background: [0, 0, 0],
}],
["39;49", { foreground: "default", background: "default" }],
// Fraktur (Gothic) that rarely supported (and parseSgr does not support as well)
["20", {}],
];
for (const [expr, expected] of testcases) {
await t.step(`properly handle "${expr}"`, () => {
const actual = parseSgr(expr);
assertEquals(actual, expected);
});
}
});