Repository navigation
Expand file tree
/
Copy pathpullRequestDescription.test.ts
More file actions
46 lines (43 loc) · 1.85 KB
/
Copy pathpullRequestDescription.test.ts
File metadata and controls
46 lines (43 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { describe, expect, it } from "vite-plus/test";
import { parseMarkdownDocument } from "../../lib/markdownDocument";
import { pullRequestDescriptionContent } from "./pullRequestDescriptionContent";
describe("pull request description content", () => {
it("ignores malformed image URLs while keeping the description and valid attachments", () => {
const result = pullRequestDescriptionContent(
parseMarkdownDocument(
[
"The pull request remains readable.",
"",
"",
'<img src="https://:80" alt="Invalid port">',
"",
"",
].join("\n\n"),
),
);
expect(result.attachments).toEqual([
{ uri: "http://example.com/screenshot.png", caption: "Screenshot", kind: "image" },
]);
expect(result.preview).toContain("The pull request remains readable.");
});
it("keeps screenshot attachments and does not turn code examples or local paths into media", () => {
const result = pullRequestDescriptionContent(
parseMarkdownDocument(
[
"Fixes reconnects.",
"```markdown\n\n```",
"",
"",
"",
"",
].join("\n\n"),
),
);
expect(result.attachments).toEqual([
{ uri: "https://example.com/before.png", caption: "Before", kind: "image" },
{ uri: "https://example.com/after.png", caption: "After", kind: "image" },
]);
expect(result.preview).toContain("Fixes reconnects.");
expect(result.preview).not.toContain("Duplicate");
});
});