Add Dart syntax highlighting (#1326)

This commit is contained in:
Mohamed Boudra
2026-06-04 18:26:23 +08:00
committed by GitHub
parent de9d796567
commit 1daa4587e5
3 changed files with 21 additions and 0 deletions
@@ -46,6 +46,22 @@ describe("highlightCode", () => {
expect(stringToken?.style).toBe("string");
});
it("highlights Dart code", () => {
const code = 'class Greeter {\n final String message = "hello";\n}';
const result = highlightCode(code, "test.dart");
expect(result).toHaveLength(3);
const classToken = result[0].find((t) => t.text === "class");
expect(classToken?.style).toBe("keyword");
const finalToken = result[1].find((t) => t.text === "final");
expect(finalToken?.style).toBe("keyword");
const stringToken = result[1].find((t) => t.text.includes("hello"));
expect(stringToken?.style).toBe("string");
});
it("highlights TSX code with correct dialect", () => {
const code = 'const el = <div className="test">hello</div>;';
const result = highlightCode(code, "test.tsx");