Skip to content

Commit 69d892a

Browse files
committed
Fix tests
1 parent ff286cb commit 69d892a

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

src/test/common/utils.test.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ describe('utils', () => {
5353
});
5454

5555
describe('processPermalinks', () => {
56-
const repoOwner = 'microsoft';
5756
const repoName = 'vscode';
5857
const authority = 'github.com';
5958
const sha = 'a'.repeat(40);
@@ -65,7 +64,7 @@ describe('utils', () => {
6564

6665
it('should add data attributes when file exists locally', async () => {
6766
const html = makePermalink('src/file.ts', 10);
68-
const result = await utils.processPermalinks(html, repoOwner, repoName, authority, async () => true);
67+
const result = await utils.processPermalinks(html, repoName, authority, async () => true);
6968

7069
assert(result.includes('data-local-file="src/file.ts"'));
7170
assert(result.includes('data-start-line="10"'));
@@ -77,58 +76,58 @@ describe('utils', () => {
7776

7877
it('should set end line when range is specified', async () => {
7978
const html = makePermalink('src/file.ts', 10, 20);
80-
const result = await utils.processPermalinks(html, repoOwner, repoName, authority, async () => true);
79+
const result = await utils.processPermalinks(html, repoName, authority, async () => true);
8180

8281
assert(result.includes('data-start-line="10"'));
8382
assert(result.includes('data-end-line="20"'));
8483
});
8584

8685
it('should not modify links when file does not exist locally', async () => {
8786
const html = makePermalink('src/file.ts', 10);
88-
const result = await utils.processPermalinks(html, repoOwner, repoName, authority, async () => false);
87+
const result = await utils.processPermalinks(html, repoName, authority, async () => false);
8988

9089
assert.strictEqual(result, html);
9190
});
9291

9392
it('should not modify non-permalink links', async () => {
9493
const html = '<a href="https://example.com">example</a>';
95-
const result = await utils.processPermalinks(html, repoOwner, repoName, authority, async () => true);
94+
const result = await utils.processPermalinks(html, repoName, authority, async () => true);
9695

9796
assert.strictEqual(result, html);
9897
});
9998

10099
it('should not modify links to a different repo', async () => {
101100
const html = `<a href="https://github.com/other/repo/blob/${sha}/src/file.ts#L10">link</a>`;
102-
const result = await utils.processPermalinks(html, repoOwner, repoName, authority, async () => true);
101+
const result = await utils.processPermalinks(html, repoName, authority, async () => true);
103102

104103
assert.strictEqual(result, html);
105104
});
106105

107106
it('should skip already processed links', async () => {
108107
const html = `<a data-permalink-processed="true" href="https://github.com/microsoft/vscode/blob/${sha}/src/file.ts#L10">link</a>`;
109-
const result = await utils.processPermalinks(html, repoOwner, repoName, authority, async () => true);
108+
const result = await utils.processPermalinks(html, repoName, authority, async () => true);
110109

111110
assert.strictEqual(result, html);
112111
});
113112

114113
it('should process multiple links independently', async () => {
115114
const html = makePermalink('src/exists.ts', 1) + makePermalink('src/missing.ts', 2);
116-
const result = await utils.processPermalinks(html, repoOwner, repoName, authority, async (path) => path === 'src/exists.ts');
115+
const result = await utils.processPermalinks(html, repoName, authority, async (path) => path === 'src/exists.ts');
117116

118117
assert(result.includes('data-local-file="src/exists.ts"'));
119118
assert(!result.includes('data-local-file="src/missing.ts"'));
120119
});
121120

122121
it('should return original HTML when fileExistsCheck throws', async () => {
123122
const html = makePermalink('src/file.ts', 10);
124-
const result = await utils.processPermalinks(html, repoOwner, repoName, authority, async () => { throw new Error('fail'); });
123+
const result = await utils.processPermalinks(html, repoName, authority, async () => { throw new Error('fail'); });
125124

126125
assert.strictEqual(result, html);
127126
});
128127

129128
it('should handle links without surrounding text', async () => {
130129
const html = makePermalink('src/file.ts', 5);
131-
const result = await utils.processPermalinks(html, repoOwner, repoName, authority, async () => true);
130+
const result = await utils.processPermalinks(html, repoName, authority, async () => true);
132131

133132
assert(result.includes('link text'));
134133
assert(result.includes('data-local-file="src/file.ts"'));

0 commit comments

Comments
 (0)