forked from ANT0071/vscode-pull-request-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprComment.test.ts
More file actions
56 lines (50 loc) · 3.66 KB
/
Copy pathprComment.test.ts
File metadata and controls
56 lines (50 loc) · 3.66 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
47
48
49
50
51
52
53
54
55
56
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { default as assert } from 'assert';
import { replaceImages } from '../../github/prComment';
describe('replace images', function () {
it('github.com', function () {
const markdownBody = `Test image

test again
`;
const htmlBody = `
<p dir="auto">Test image</p><p dir="auto"><a target="_blank" rel="noopener noreferrer" href="https://private-user-images.githubusercontent.com/38270282/445632993-714215c1-e994-4c69-be20-2276c558f7c3.png?jwt=TEST"><img src="https://private-user-images.githubusercontent.com/38270282/445632993-714215c1-e994-4c69-be20-2276c558f7c3.png?jwt=TEST" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">test again</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer" href="https://private-user-images.githubusercontent.com/38270282/445689518-3f2c170a-d0c3-4ac7-a9e5-ea13bf71a5bc.png?jwt=TEST"><img src="https://private-user-images.githubusercontent.com/38270282/445689518-3f2c170a-d0c3-4ac7-a9e5-ea13bf71a5bc.png?jwt=TEST" alt="image" style="max-width: 100%;"></a></p>`;
const host = 'github.com';
const replaced = replaceImages(markdownBody, htmlBody, host);
const expected = `Test image

test again
`;
assert.strictEqual(replaced, expected);
});
it('GHCE', function () {
const markdownBody = `Test image
`;
const htmlBody = `
<p dir="auto">Test image</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer" href="https://test.ghe.com/github-production-user-asset-6210df/11296/2514616-d81c6ab2-52a6-4ebf-b0c8-125492bd9662.png?TEST"><img src="https://objects-origin.test.ghe.com/github-production-user-asset-6210df/11296/2514616-d81c6ab2-52a6-4ebf-b0c8-125492bd9662.png?TEST" alt="image" style="max-width: 100%;"></a></p>`;
const host = 'test.ghe.com';
const replaced = replaceImages(markdownBody, htmlBody, host);
const expected = `Test image
`;
assert.strictEqual(replaced, expected);
});
it('GHE', function () {
const markdownBody = `Test

`;
const htmlBody = ` <p dir="auto">Test<br>
<a target="_blank" rel="noopener noreferrer" href="https://media.alexr00-my-test-instance.ghe-test.com/user/6/files/c267d6ce-fbdd-41a0-b86d-760882bd0c82?TEST"><img src="https://media.alexr00-my-test-instance.ghe-test.com/user/6/files/c267d6ce-fbdd-41a0-b86d-760882bd0c82?TEST" alt="image" style="max-width: 100%;"></a></p>`;
const host = 'alexr00-my-test-instance.ghe-test.com';
const replaced = replaceImages(markdownBody, htmlBody, host);
const expected = `Test

`;
assert.strictEqual(replaced, expected);
});
});