Skip to content

Commit bf41e29

Browse files
committed
Added unit tests
1 parent c3cfc3a commit bf41e29

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Replace
2+
3+
[#8](https://github.com/username/repository/issues/8)
4+
5+
* Some issue in same repository: [#7](https://github.com/username/repository/issues/7)
6+
* Some issue in other repository: [other/repositoryName#8](https://github.com/other/repositoryName/issues/8)
7+
* Some issue in other repository with fancy name: [my_user-name/my-rep_o12#6](https://github.com/my_user-name/my-rep_o12/issues/6)
8+
9+
# Do not touch this:
10+
* username#4 (no valid github link)
11+
* /#7
12+
* foo/$234/#7
13+
* [#7](http://shouldnottouchthis/)
14+
* [other/repositoryName#8](http://shouldnottouchthis/)
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Replace
2+
3+
#8
4+
5+
* Some issue in same repository: #7
6+
* Some issue in other repository: other/repositoryName#8
7+
* Some issue in other repository with fancy name: my_user-name/my-rep_o12#6
8+
9+
# Do not touch this:
10+
* username#4 (no valid github link)
11+
* /#7
12+
* foo/$234/#7
13+
* [#7](http://shouldnottouchthis/)
14+
* [other/repositoryName#8](http://shouldnottouchthis/)

src/test/package.test.ts

+54
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,60 @@ describe('MarkdownProcessor', () => {
15001500
});
15011501
});
15021502

1503+
it('should replace issue links with urls if its a github repo.', () => {
1504+
const manifest = {
1505+
name: 'test',
1506+
publisher: 'mocha',
1507+
version: '0.0.1',
1508+
description: 'test extension',
1509+
engines: Object.create(null),
1510+
repository: 'https://github.com/username/repository.git'
1511+
};
1512+
1513+
const root = fixture('readme');
1514+
const processor = new ReadmeProcessor(manifest, {});
1515+
const readme = {
1516+
path: 'extension/readme.md',
1517+
localPath: path.join(root, 'readme.github.md')
1518+
};
1519+
1520+
return processor.onFile(readme)
1521+
.then(file => read(file))
1522+
.then(actual => {
1523+
return readFile(path.join(root, 'readme.github.expected.md'), 'utf8')
1524+
.then(expected => {
1525+
assert.equal(actual, expected);
1526+
});
1527+
});
1528+
});
1529+
1530+
it('should not replace issue links with urls if its not a github repo.', () => {
1531+
const manifest = {
1532+
name: 'test',
1533+
publisher: 'mocha',
1534+
version: '0.0.1',
1535+
description: 'test extension',
1536+
engines: Object.create(null),
1537+
repository: 'https://some-other-provider.com/username/repository.git'
1538+
};
1539+
1540+
const root = fixture('readme');
1541+
const processor = new ReadmeProcessor(manifest, {});
1542+
const readme = {
1543+
path: 'extension/readme.md',
1544+
localPath: path.join(root, 'readme.github.md')
1545+
};
1546+
1547+
return processor.onFile(readme)
1548+
.then(file => read(file))
1549+
.then(actual => {
1550+
return readFile(path.join(root, 'readme.github.md'), 'utf8')
1551+
.then(expected => {
1552+
assert.equal(actual, expected);
1553+
});
1554+
});
1555+
});
1556+
15031557
it('should prevent non-HTTPS images', async () => {
15041558
const manifest = { name: 'test', publisher: 'mocha', version: '0.0.1', engines: Object.create(null), repository: 'https://github.com/username/repository' };
15051559
const contents = `![title](http://foo.png)`;

0 commit comments

Comments
 (0)