File tree 3 files changed +40
-12
lines changed
3 files changed +40
-12
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ function evaluate(fn) {
25
25
) ;
26
26
}
27
27
28
+ afterEach ( function ( ) {
29
+ mock . restore ( ) ;
30
+ } ) ;
31
+
28
32
test ( 'github' , function ( ) {
29
33
mock ( mockRepo . master ) ;
30
34
@@ -42,8 +46,6 @@ test('github', function() {
42
46
path : 'index.js' ,
43
47
url : 'https://github.com/foo/bar/blob/this_is_the_sha/index.js#L6-L8'
44
48
} ) ;
45
-
46
- mock . restore ( ) ;
47
49
} ) ;
48
50
49
51
test ( 'malformed repository' , function ( ) {
@@ -60,8 +62,6 @@ test('malformed repository', function() {
60
62
}
61
63
} ) [ 0 ] . context . github
62
64
) . toBe ( undefined ) ;
63
-
64
- mock . restore ( ) ;
65
65
} ) ;
66
66
67
67
test ( 'enterprise repository' , function ( ) {
@@ -82,6 +82,28 @@ test('enterprise repository', function() {
82
82
url :
83
83
'https://github.enterprise.com/foo/bar/blob/this_is_the_sha/index.js#L6-L8'
84
84
} ) ;
85
+ } ) ;
85
86
86
- mock . restore ( ) ;
87
+ test ( 'typedef' , function ( ) {
88
+ mock ( mockRepo . master ) ;
89
+
90
+ expect (
91
+ evaluate ( function ( ) {
92
+ /**
93
+ * A number, or a string containing a number.
94
+ * @typedef {(number|string) } NumberLike
95
+ */
96
+
97
+ /**
98
+ * get one
99
+ * @returns {number } one
100
+ */
101
+ function getOne ( ) {
102
+ return 1 ;
103
+ }
104
+ } ) [ 0 ] . context . github
105
+ ) . toEqual ( {
106
+ path : 'index.js' ,
107
+ url : 'https://github.com/foo/bar/blob/this_is_the_sha/index.js#L2-L5'
108
+ } ) ;
87
109
} ) ;
Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ type Comment = {
106
106
type ?: DoctrineType ,
107
107
108
108
context : CommentContext ,
109
+ loc : CommentLoc ,
109
110
110
111
path ?: Array < {
111
112
name : string ,
Original file line number Diff line number Diff line change @@ -21,15 +21,20 @@ module.exports = function(comment: Comment) {
21
21
. join ( '/' ) ;
22
22
23
23
if ( urlPrefix ) {
24
+ let startLine ;
25
+ let endLine ;
26
+
27
+ if ( comment . kind == 'typedef' ) {
28
+ startLine = comment . loc . start . line ;
29
+ endLine = comment . loc . end . line ;
30
+ } else {
31
+ startLine = comment . context . loc . start . line ;
32
+ endLine = comment . context . loc . end . line ;
33
+ }
34
+
24
35
comment . context . github = {
25
36
url :
26
- urlPrefix +
27
- fileRelativePath +
28
- '#L' +
29
- comment . context . loc . start . line +
30
- '-' +
31
- 'L' +
32
- comment . context . loc . end . line ,
37
+ urlPrefix + fileRelativePath + '#L' + startLine + '-' + 'L' + endLine ,
33
38
path : fileRelativePath
34
39
} ;
35
40
}
You can’t perform that action at this time.
0 commit comments