Skip to content

Commit db16ec2

Browse files
kendyl93claude
andcommitted
test(web): cover chip punctuation pairing
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 87c1fdc commit db16ec2

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
});

0 commit comments

Comments
 (0)