|
1 | 1 | import { describe, expect, it } from "vite-plus/test"; |
2 | 2 | import { azureDevOpsMarkdownLinks, githubMarkdownLinks } from "./githubMarkdownLinks.ts"; |
| 3 | +import { unified } from "unified"; |
| 4 | +import remarkParse from "remark-parse"; |
3 | 5 |
|
4 | 6 | const url = "https://github.com/team/repo/pull/8"; |
5 | 7 | describe("githubMarkdownLinks", () => { |
@@ -36,18 +38,27 @@ describe("githubMarkdownLinks", () => { |
36 | 38 |
|
37 | 39 | describe("Azure DevOps references", () => { |
38 | 40 | const repo = "https://dev.azure.com/acme/project/_git/repo"; |
| 41 | + it("keeps unmatched parentheses in Azure link destinations", () => { |
| 42 | + const repository = "https://dev.azure.com/acme/project)/_git/repo("; |
| 43 | + const markdown = azureDevOpsMarkdownLinks("!34", repository); |
| 44 | + expect(unified().use(remarkParse).parse(markdown).children[0]).toMatchObject({ |
| 45 | + children: [{ type: "link", url: `${repository}/pullrequest/34` }], |
| 46 | + }); |
| 47 | + }); |
39 | 48 | it("distinguishes work items, pull requests, and native mentions", () => { |
40 | 49 | const identity = "abcdef01-1234-5678-1234-abcdef012345"; |
41 | 50 | const result = azureDevOpsMarkdownLinks(`See #12, !34 and @<${identity}>.`, repo, { |
42 | 51 | [identity]: "A [reviewer]", |
43 | 52 | }); |
44 | | - expect(result).toContain("[#12](https://dev.azure.com/acme/project/_workitems/edit/12)"); |
45 | | - expect(result).toContain("[!34](https://dev.azure.com/acme/project/_git/repo/pullrequest/34)"); |
| 53 | + expect(result).toContain("[#12](<https://dev.azure.com/acme/project/_workitems/edit/12>)"); |
| 54 | + expect(result).toContain( |
| 55 | + "[!34](<https://dev.azure.com/acme/project/_git/repo/pullrequest/34>)", |
| 56 | + ); |
46 | 57 | expect(result).toContain("@A \\[reviewer\\]"); |
47 | 58 | expect(result).not.toContain("@<"); |
48 | 59 | const commit = "0123456789abcdef0123456789abcdef01234567"; |
49 | 60 | expect(azureDevOpsMarkdownLinks(`Fixed in ${commit}`, repo)).toBe( |
50 | | - `Fixed in [0123456](${repo}/commit/${commit})`, |
| 61 | + `Fixed in [0123456](<${repo}/commit/${commit}>)`, |
51 | 62 | ); |
52 | 63 | }); |
53 | 64 | it("leaves code, authored links, escaped references and HTML code unchanged", () => { |
|
0 commit comments