Repository navigation
Expand file tree
/
Copy pathicons.test.ts
More file actions
56 lines (51 loc) · 1.44 KB
/
Copy pathicons.test.ts
File metadata and controls
56 lines (51 loc) · 1.44 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
46
47
48
49
50
51
52
53
54
55
56
// @vitest-environment happy-dom
import { describe, it, expect } from "vite-plus/test";
import { icon } from "../src/icons";
describe("icons module", () => {
it("creates an SVGSVGElement with default size 16", () => {
const el = icon("search");
expect(el).toBeInstanceOf(SVGSVGElement);
expect(el.getAttribute("width")).toBe("16");
expect(el.getAttribute("height")).toBe("16");
expect(el.children.length).toBeGreaterThan(0);
});
it("creates an SVGSVGElement with custom specified size", () => {
const el = icon("zap", 24);
expect(el.getAttribute("width")).toBe("24");
expect(el.getAttribute("height")).toBe("24");
});
it("handles all registered icon names without throwing errors", () => {
const iconNames = [
"folder",
"folderOpen",
"file",
"paperclip",
"x",
"chevronRight",
"chevronDown",
"arrowLeft",
"plus",
"download",
"zap",
"search",
"settings",
"upload",
"copy",
"save",
"terminal",
"code",
"binary",
"dot",
];
iconNames.forEach((name) => {
const el = icon(name);
expect(el).toBeInstanceOf(SVGSVGElement);
expect(el.children.length).toBeGreaterThan(0);
});
});
it("returns empty SVG element for unknown icon names", () => {
const el = icon("non_existent_icon_xyz");
expect(el).toBeInstanceOf(SVGSVGElement);
expect(el.children.length).toBe(0);
});
});