The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { assert, describe, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { |
| 4 | hasSpecificPierreIconForFileName, |
| 5 | resolvePierreIconForEntry, |
| 6 | syntheticFileNameForLanguageId, |
| 7 | T3_PIERRE_ICONS, |
| 8 | } from "./pierre-icons"; |
| 9 | |
| 10 | describe("Pierre file icons", () => { |
| 11 | it.each(["photo.heic", "photo.heif", "PHOTO.HEIC", "folder/photo.HEIF"])( |
| 12 | "uses the image icon for %s", |
| 13 | (name) => { |
| 14 | assert.equal(resolvePierreIconForEntry(name, "file")?.token, "image"); |
| 15 | assert.isTrue(hasSpecificPierreIconForFileName(name)); |
| 16 | }, |
| 17 | ); |
| 18 | it("uses detected types for extensionless files while keeping known filename icons", () => { |
| 19 | assert.equal( |
| 20 | resolvePierreIconForEntry("custom-script", "file", "text/x-python")?.token, |
| 21 | "python", |
| 22 | ); |
| 23 | assert.equal(resolvePierreIconForEntry("image", "file", "image/png")?.token, "image"); |
| 24 | assert.equal( |
| 25 | resolvePierreIconForEntry("Dockerfile", "file", "text/x-shellscript")?.token, |
| 26 | "docker", |
| 27 | ); |
| 28 | assert.isNull(resolvePierreIconForEntry("folder.png", "directory", "image/png")); |
| 29 | assert.equal( |
| 30 | resolvePierreIconForEntry("unknown", "file", "application/octet-stream")?.token, |
| 31 | "default", |
| 32 | ); |
| 33 | }); |
| 34 | |
| 35 | it.each([ |
| 36 | ["pdf", "pdf"], |
| 37 | ["doc", "word"], |
| 38 | ["docx", "word"], |
| 39 | ["odt", "word"], |
| 40 | ["rtf", "word"], |
| 41 | ["xls", "spreadsheet"], |
| 42 | ["xlsx", "spreadsheet"], |
| 43 | ["ods", "spreadsheet"], |
| 44 | ["csv", "spreadsheet"], |
| 45 | ["tsv", "spreadsheet"], |
| 46 | ["ppt", "slides"], |
| 47 | ["pptx", "slides"], |
| 48 | ["odp", "slides"], |
| 49 | ["epub", "epub"], |
| 50 | ])("uses the document family icon for %s", (extension, family) => { |
| 51 | for (const path of [`report.${extension}`, `folder/REPORT.${extension.toUpperCase()}`]) { |
| 52 | assert.equal(resolvePierreIconForEntry(path, "file")?.name, `t3-file-icon-${family}`); |
| 53 | assert.isTrue(hasSpecificPierreIconForFileName(path)); |
| 54 | } |
| 55 | }); |
| 56 | |
| 57 | it("ships every custom icon referenced by the extended resolver", () => { |
| 58 | const customIconNames = new Set( |
| 59 | [ |
| 60 | ...Object.values(T3_PIERRE_ICONS.byFileName), |
| 61 | ...Object.values(T3_PIERRE_ICONS.byFileExtension), |
| 62 | ].filter((name) => name.startsWith("t3-")), |
| 63 | ); |
| 64 | for (const iconName of customIconNames) { |
| 65 | assert.include(T3_PIERRE_ICONS.spriteSheet, `id="${iconName}"`); |
| 66 | } |
| 67 | }); |
| 68 | |
| 69 | it.each([ |
| 70 | ["luau", "lua"], |
| 71 | ["xsd", "xml"], |
| 72 | ["xsl", "xml"], |
| 73 | ["xslt", "xml"], |
| 74 | ])("gives %s files and fences the %s icon", (dialect, base) => { |
| 75 | const baseIcon = resolvePierreIconForEntry(`file.${base}`, "file")?.name; |
| 76 | assert.equal(baseIcon, `t3-file-icon-${base}`); |
| 77 | for (const path of [`src/init.${dialect}`, `src/INIT.${dialect.toUpperCase()}`]) { |
| 78 | assert.equal(resolvePierreIconForEntry(path, "file")?.name, baseIcon); |
| 79 | assert.isTrue(hasSpecificPierreIconForFileName(path)); |
| 80 | } |
| 81 | assert.equal( |
| 82 | resolvePierreIconForEntry(syntheticFileNameForLanguageId(dialect), "file")?.name, |
| 83 | baseIcon, |
| 84 | ); |
| 85 | }); |
| 86 | }); |