The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { codeFenceRenderer, fencedCodeMarkdown } from "./codeBlockMarkdown"; |
| 4 | |
| 5 | describe("fencedCodeMarkdown", () => { |
| 6 | it.each([ |
| 7 | ["a plain fence", "fun main() {}", "kotlin", "```kotlin\nfun main() {}\n```"], |
| 8 | ["a longer fence than the code's", "```\nx\n```", "md", "````md\n```\nx\n```\n````"], |
| 9 | ["no language", "x", "", "```\nx\n```"], |
| 10 | ])("writes %s", (_, code, language, expected) => { |
| 11 | expect(fencedCodeMarkdown(code, language)).toBe(expected); |
| 12 | }); |
| 13 | }); |
| 14 | |
| 15 | describe("codeFenceRenderer", () => { |
| 16 | it.each([ |
| 17 | ["mermaid", true, { kind: "mermaid" }], |
| 18 | ["math", true, { kind: "math" }], |
| 19 | ["math", false, { kind: "native" }], |
| 20 | ["kotlin", true, { kind: "highlight", language: "kotlin" }], |
| 21 | ["KOTLIN", true, { kind: "highlight", language: "kotlin" }], |
| 22 | ["diff", true, { kind: "highlight", language: "diff" }], |
| 23 | ["ts", true, { kind: "native" }], |
| 24 | ["python", true, { kind: "native" }], |
| 25 | ["", true, { kind: "native" }], |
| 26 | ["text", true, { kind: "native" }], |
| 27 | ])("draws %j with math rendering %s as %j", (fence, mathRenderingEnabled, expected) => { |
| 28 | expect(codeFenceRenderer(fence, mathRenderingEnabled)).toEqual(expected); |
| 29 | }); |
| 30 | }); |