File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
var test = require ( 'tap' ) . test ,
4
+ mock = require ( 'mock-fs' ) ,
5
+ mockRepo = require ( './git/mock_repo' ) ,
4
6
parse = require ( '../../lib/parsers/javascript' ) ,
5
7
github = require ( '../../lib/github' ) ;
6
8
7
9
function toComment ( fn , filename ) {
8
10
return parse ( {
9
11
file : filename ,
10
12
source : fn instanceof Function ? '(' + fn . toString ( ) + ')' : fn
11
- } ) [ 0 ] ;
13
+ } ) . map ( github ) ;
12
14
}
13
15
14
16
function evaluate ( fn ) {
15
- return toComment ( fn , 'input .js' ) ;
17
+ return toComment ( fn , '/my/repository/path/index .js' ) ;
16
18
}
17
19
18
20
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
+
19
38
t . end ( ) ;
20
39
} ) ;
You can’t perform that action at this time.
0 commit comments