Files
outline/shared/utils/parseMentionUrl.test.ts
T
Tom Moor 7dc1d12d3b feat: Support simplified mention syntax in markdown for MCP (#11851)
* feat: Support simplified mention syntax in markdown for MCP clients

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Restore translations

* PR feedback

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 08:08:24 -04:00

59 lines
1.6 KiB
TypeScript

import parseMentionUrl from "./parseMentionUrl";
describe("parseMentionUrl", () => {
it("should parse 3-segment mention URL", () => {
expect(
parseMentionUrl(
"mention://9a17c1c8-d178-4350-9001-203a73070fcb/user/abc123def456"
)
).toEqual({
id: "9a17c1c8-d178-4350-9001-203a73070fcb",
mentionType: "user",
modelId: "abc123def456",
});
});
it("should parse 2-segment mention URL", () => {
expect(parseMentionUrl("mention://user/abc123def456")).toEqual({
mentionType: "user",
modelId: "abc123def456",
});
});
it("should parse 2-segment mention URL with UUID modelId", () => {
expect(
parseMentionUrl("mention://user/9a17c1c8-d178-4350-9001-203a73070fcb")
).toEqual({
mentionType: "user",
modelId: "9a17c1c8-d178-4350-9001-203a73070fcb",
});
});
it("should parse group mention type", () => {
expect(parseMentionUrl("mention://group/abc123")).toEqual({
mentionType: "group",
modelId: "abc123",
});
});
it("should parse pull_request mention type with underscore", () => {
expect(
parseMentionUrl(
"mention://9a17c1c8-d178-4350-9001-203a73070fcb/pull_request/abc123"
)
).toEqual({
id: "9a17c1c8-d178-4350-9001-203a73070fcb",
mentionType: "pull_request",
modelId: "abc123",
});
});
it("should return empty object for invalid URL", () => {
expect(parseMentionUrl("https://example.com")).toEqual({});
});
it("should return empty object for empty string", () => {
expect(parseMentionUrl("")).toEqual({});
});
});