Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { serializeComposerFileLink, serializeComposerMentionPath } from "./composerTrigger.ts";
4
5describe("serializeComposerMentionPath", () => {
6 it("keeps simple mention paths unquoted", () => {
7 expect(serializeComposerMentionPath("src/index.ts")).toBe("src/index.ts");
8 });
9
10 it("quotes mention paths containing whitespace", () => {
11 expect(serializeComposerMentionPath("docs/My File.md")).toBe('"docs/My File.md"');
12 });
13
14 it("escapes quoted mention path content", () => {
15 expect(serializeComposerMentionPath('docs/My "File".md')).toBe('"docs/My \\"File\\".md"');
16 });
17});
18
19describe("serializeComposerFileLink", () => {
20 it("uses the basename as the markdown label", () => {
21 expect(serializeComposerFileLink("path/to/package.json")).toBe(
22 "[package.json](path/to/package.json)",
23 );
24 });
25
26 it("encodes markdown-sensitive destination characters", () => {
27 expect(serializeComposerFileLink("docs/My File (draft).md")).toBe(
28 "[My File (draft).md](docs/My%20File%20%28draft%29.md)",
29 );
30 });
31
32 it("supports windows paths", () => {
33 expect(serializeComposerFileLink("C:\\repo\\src\\index.ts")).toBe(
34 "[index.ts](C:%5Crepo%5Csrc%5Cindex.ts)",
35 );
36 });
37
38 it("preserves paths that legitimately start with an at sign", () => {
39 expect(serializeComposerFileLink("@scope/package.json")).toBe(
40 "[package.json](@scope/package.json)",
41 );
42 });
43});