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, 04:45 UTC
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { rehypeChipPunctuation } from "./markdownChipPunctuation"; |
| 4 | |
| 5 | const text = (value: string) => ({ type: "text", value }); |
| 6 | const element = (tagName: string, children: object[]) => ({ |
| 7 | type: "element", |
| 8 | tagName, |
| 9 | properties: {} as Record<string, unknown>, |
| 10 | children, |
| 11 | }); |
| 12 | |
| 13 | function paired(block: ReturnType<typeof element>) { |
| 14 | rehypeChipPunctuation()({ type: "root", children: [block] }); |
| 15 | return block.children; |
| 16 | } |
| 17 | |
| 18 | describe("rehypeChipPunctuation", () => { |
| 19 | it("pairs a link with the punctuation that follows it", () => { |
| 20 | const link = element("a", [text("a.ts")]); |
| 21 | expect(paired(element("p", [text("See "), link, text("... next")]))).toEqual([ |
| 22 | text("See "), |
| 23 | expect.objectContaining({ tagName: "span", children: [link, text("...")] }), |
| 24 | text(" next"), |
| 25 | ]); |
| 26 | }); |
| 27 | |
| 28 | it("leaves code blocks alone", () => { |
| 29 | const children = [element("code", [text("a.ts")]), text(".")]; |
| 30 | expect(paired(element("pre", [...children]))).toEqual(children); |
| 31 | }); |
| 32 | }); |