Files
t3code/packages/shared/src/composerTrigger.test.ts
T
7f741a56d1 Misc markdown styling improvements (#3017)
Co-authored-by: ss <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
Co-authored-by: codex <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
2026-06-09 21:21:58 -07:00

44 lines
1.4 KiB
TypeScript

import { describe, expect, it } from "vite-plus/test";
import { serializeComposerFileLink, serializeComposerMentionPath } from "./composerTrigger.ts";
describe("serializeComposerMentionPath", () => {
it("keeps simple mention paths unquoted", () => {
expect(serializeComposerMentionPath("src/index.ts")).toBe("src/index.ts");
});
it("quotes mention paths containing whitespace", () => {
expect(serializeComposerMentionPath("docs/My File.md")).toBe('"docs/My File.md"');
});
it("escapes quoted mention path content", () => {
expect(serializeComposerMentionPath('docs/My "File".md')).toBe('"docs/My \\"File\\".md"');
});
});
describe("serializeComposerFileLink", () => {
it("uses the basename as the markdown label", () => {
expect(serializeComposerFileLink("path/to/package.json")).toBe(
"[package.json](path/to/package.json)",
);
});
it("encodes markdown-sensitive destination characters", () => {
expect(serializeComposerFileLink("docs/My File (draft).md")).toBe(
"[My File (draft).md](docs/My%20File%20%28draft%29.md)",
);
});
it("supports windows paths", () => {
expect(serializeComposerFileLink("C:\\repo\\src\\index.ts")).toBe(
"[index.ts](C:%5Crepo%5Csrc%5Cindex.ts)",
);
});
it("preserves paths that legitimately start with an at sign", () => {
expect(serializeComposerFileLink("@scope/package.json")).toBe(
"[package.json](@scope/package.json)",
);
});
});