Repository navigation
Expand file tree
/
Copy pathParseColorTest.js
More file actions
45 lines (43 loc) · 1.49 KB
/
Copy pathParseColorTest.js
File metadata and controls
45 lines (43 loc) · 1.49 KB
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
import { deepEqual } from "node:assert";
import { test } from "node:test";
import { parseColor } from "../../main/js/utils.js";
test("ParseColor", () => {
const tests = [
["#FFFFFF", [255, 255, 255, 255]],
["#FFFFFF7F", [255, 255, 255, 127]],
["rgb(255,128,255)", [255, 128, 255, 255]],
["rgb( 255, 128 , 255 )", [255, 128, 255, 255]],
["rgba(128,255,255,63)", [128, 255, 255, 63]],
["transparent", [0, 0, 0, 0]],
["black", [0, 0, 0, 255]],
["silver", [0xc0, 0xc0, 0xc0, 255]],
["gray", [0x80, 0x80, 0x80, 255]],
["white", [255, 255, 255, 255]],
["maroon", [0x80, 0, 0, 255]],
["red", [255, 0, 0, 255]],
["purple", [0x80, 0, 0x80, 255]],
["fuchsia", [255, 0, 255, 255]],
["magenta", [255, 0, 255, 255]],
["green", [0, 0x80, 0, 255]],
["lime", [0, 255, 0, 255]],
["olive", [0x80, 0x80, 0, 255]],
["yellow", [255, 255, 0, 255]],
["navy", [0, 0, 0x80, 255]],
["blue", [0, 0, 255, 255]],
["teal", [0, 0x80, 0x80, 255]],
["aqua", [0, 255, 255, 255]],
["cyan", [0, 255, 255, 255]],
["Cyan", [0, 255, 255, 255]],
["CYAN", [0, 255, 255, 255]],
["#FFffFF", [255, 255, 255, 255]],
["#FfFFFF7f", [255, 255, 255, 127]],
["#red", null],
];
for (const i in tests) {
deepEqual(
parseColor(tests[i][0]),
tests[i][1],
tests[i][0],
);
}
});