The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { getFiletypeFromFileName } from "@pierre/diffs"; |
| 2 | import { describe, expect, it } from "vite-plus/test"; |
| 3 | |
| 4 | import { getSyntaxHighlighterPromise } from "./syntaxHighlighting"; |
| 5 | import { DIFF_THEME_NAMES } from "./diffRendering"; |
| 6 | |
| 7 | describe("dialect file types", () => { |
| 8 | it.each([ |
| 9 | ["src/init.luau", "lua"], |
| 10 | ["styles/page.xsl", "xml"], |
| 11 | ["styles/page.xslt", "xml"], |
| 12 | ])("%s highlights as %s", (path, language) => { |
| 13 | expect(getFiletypeFromFileName(path)).toBe(language); |
| 14 | }); |
| 15 | }); |
| 16 | |
| 17 | it.each([ |
| 18 | "asm", |
| 19 | "assembly", |
| 20 | "s", |
| 21 | ...["asm", "ASM", "s", "S", "nasm", "NASM"].map((ext) => `src/start.${ext}`), |
| 22 | ])("highlights assembly in %s", async (hint) => { |
| 23 | const language = hint.includes("/") ? getFiletypeFromFileName(hint) : hint; |
| 24 | const highlighter = await getSyntaxHighlighterPromise(language); |
| 25 | const code = "mov eax, 42 ; answer\nret"; |
| 26 | for (const theme of Object.values(DIFF_THEME_NAMES)) { |
| 27 | const { tokens } = highlighter.codeToTokens(code, { lang: language, theme }); |
| 28 | expect(tokens.map((line) => line.map((token) => token.content).join("")).join("\n")).toBe(code); |
| 29 | expect(new Set(tokens.flat().map((token) => token.color)).size).toBeGreaterThan(1); |
| 30 | } |
| 31 | }); |