Open History to see the last commit
1import { assert, describe, it } from "vitest";
2
3import { getVscodeIconUrlForEntry } from "./vscode-icons";
4
5describe("getVscodeIconUrlForEntry", () => {
6 it("uses exact filename matches from the vscode-icons manifest", () => {
7 const darkUrl = getVscodeIconUrlForEntry("pnpm-workspace.yaml", "file", "dark");
8 const lightUrl = getVscodeIconUrlForEntry("pnpm-workspace.yaml", "file", "light");
9
10 assert.isTrue(darkUrl.endsWith("/file_type_pnpm.svg"));
11 assert.isTrue(lightUrl.endsWith("/file_type_light_pnpm.svg"));
12 });
13
14 it("uses longest extension match for compound extensions", () => {
15 const iconUrl = getVscodeIconUrlForEntry("tsconfig.tsbuildinfo", "file", "dark");
16 const manifestStyleUrl = getVscodeIconUrlForEntry("buf.yaml", "file", "dark");
17 assert.isTrue(iconUrl.endsWith("/file_type_tsbuildinfo.svg"));
18 assert.isTrue(manifestStyleUrl.endsWith("/file_type_buf.svg"));
19 });
20
21 it("uses folder mappings and light-aware filename mappings", () => {
22 const folderUrl = getVscodeIconUrlForEntry("packages/src", "directory", "light");
23 const fileUrl = getVscodeIconUrlForEntry("AGENTS.md", "file", "light");
24
25 assert.isTrue(folderUrl.endsWith("/folder_type_src.svg"));
26 assert.isTrue(fileUrl.endsWith("/file_type_light_agents.svg"));
27 });
28
29 it("falls back to language-based mappings for path-only cases", () => {
30 const tsxUrl = getVscodeIconUrlForEntry("checkbox.tsx", "file", "light");
31 const dockerfileUrl = getVscodeIconUrlForEntry("Dockerfile", "file", "dark");
32 const shellUrl = getVscodeIconUrlForEntry("entrypoint.sh", "file", "dark");
33 const cursorRulesUrl = getVscodeIconUrlForEntry("general.mdc", "file", "dark");
34 const githubWorkflowUrl = getVscodeIconUrlForEntry(".github/workflows/ci.yml", "file", "light");
35
36 assert.isTrue(tsxUrl.endsWith("/file_type_reactts.svg"));
37 assert.isTrue(dockerfileUrl.endsWith("/file_type_docker.svg"));
38 assert.isTrue(shellUrl.endsWith("/file_type_shell.svg"));
39 assert.isTrue(cursorRulesUrl.endsWith("/file_type_markdown.svg"));
40 assert.isTrue(githubWorkflowUrl.endsWith("/file_type_light_yaml.svg"));
41 });
42
43 it("falls back to defaults when there is no match", () => {
44 const fileUrl = getVscodeIconUrlForEntry("foo.unknown-ext", "file", "dark");
45 const folderUrl = getVscodeIconUrlForEntry("totally-unknown-folder", "directory", "dark");
46
47 assert.isTrue(fileUrl.endsWith("/default_file.svg"));
48 assert.isTrue(folderUrl.endsWith("/default_folder.svg"));
49 });
50});