Add Dart syntax highlighting (#1326)
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -14,6 +14,7 @@ describe("isLanguageSupported", () => {
|
||||
expect(isLanguageSupported("test.html")).toBe(true);
|
||||
expect(isLanguageSupported("test.java")).toBe(true);
|
||||
expect(isLanguageSupported("test.swift")).toBe(true);
|
||||
expect(isLanguageSupported("test.dart")).toBe(true);
|
||||
expect(isLanguageSupported("test.ex")).toBe(true);
|
||||
});
|
||||
|
||||
@@ -51,6 +52,7 @@ describe("getSupportedExtensions", () => {
|
||||
expect(extensions).toContain("go");
|
||||
expect(extensions).toContain("rs");
|
||||
expect(extensions).toContain("swift");
|
||||
expect(extensions).toContain("dart");
|
||||
expect(extensions).toContain("json");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user