Skip to content

Commit bcb9e81

Browse files
committed
Add tests for github processor
1 parent 791dcaf commit bcb9e81

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

test/lib/github.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
11
'use strict';
22

33
var test = require('tap').test,
4+
mock = require('mock-fs'),
5+
mockRepo = require('./git/mock_repo'),
46
parse = require('../../lib/parsers/javascript'),
57
github = require('../../lib/github');
68

79
function toComment(fn, filename) {
810
return parse({
911
file: filename,
1012
source: fn instanceof Function ? '(' + fn.toString() + ')' : fn
11-
})[0];
13+
}).map(github);
1214
}
1315

1416
function evaluate(fn) {
15-
return toComment(fn, 'input.js');
17+
return toComment(fn, '/my/repository/path/index.js');
1618
}
1719

1820
test('github', function (t) {
21+
22+
mock(mockRepo);
23+
24+
t.equal(evaluate(function () {
25+
/**
26+
* get one
27+
* @returns {number} one
28+
*/
29+
function getOne() {
30+
return 1;
31+
}
32+
})[0].context.github,
33+
'https://github.com/foo/bar/blob/this_is_the_sha/index.js#L6-L8',
34+
'gets github url');
35+
36+
mock.restore();
37+
1938
t.end();
2039
});

0 commit comments

Comments
 (0)