Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

vscode-icons.test.ts

52 lines2.6 KB

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 htmlUrl = getVscodeIconUrlForEntry("index.html", "file", "dark");
34 const cursorRulesUrl = getVscodeIconUrlForEntry("general.mdc", "file", "dark");
35 const githubWorkflowUrl = getVscodeIconUrlForEntry(".github/workflows/ci.yml", "file", "light");
36​
37 assert.isTrue(tsxUrl.endsWith("/file_type_reactts.svg"));
38 assert.isTrue(dockerfileUrl.endsWith("/file_type_docker.svg"));
39 assert.isTrue(shellUrl.endsWith("/file_type_shell.svg"));
40 assert.isTrue(htmlUrl.endsWith("/file_type_html.svg"));
41 assert.isTrue(cursorRulesUrl.endsWith("/file_type_markdown.svg"));
42 assert.isTrue(githubWorkflowUrl.endsWith("/file_type_light_yaml.svg"));
43 });
44​
45 it("falls back to defaults when there is no match", () => {
46 const fileUrl = getVscodeIconUrlForEntry("foo.unknown-ext", "file", "dark");
47 const folderUrl = getVscodeIconUrlForEntry("totally-unknown-folder", "directory", "dark");
48​
49 assert.isTrue(fileUrl.endsWith("/default_file.svg"));
50 assert.isTrue(folderUrl.endsWith("/default_folder.svg"));
51 });
52});