@@ -196,14 +196,28 @@ describe('commentsAbove', () => {
196
196
it ( 'returns a string of a comment block above a line' , ( ) => {
197
197
analyzer . analyze ( CURRENT_URI , FIXTURES . COMMENT_DOC )
198
198
expect ( analyzer . commentsAbove ( CURRENT_URI , 22 ) ) . toEqual ( 'doc for func_one' )
199
+ } )
199
200
201
+ it ( 'handles line breaks in comments' , ( ) => {
202
+ analyzer . analyze ( CURRENT_URI , FIXTURES . COMMENT_DOC )
200
203
expect ( analyzer . commentsAbove ( CURRENT_URI , 28 ) ) . toEqual (
201
- 'doc for func_two\nhas two lines' ,
204
+ 'doc for func_two\nhas two lines' ,
202
205
)
206
+ } )
207
+
208
+ it ( 'only returns connected comments' , ( ) => {
209
+ analyzer . analyze ( CURRENT_URI , FIXTURES . COMMENT_DOC )
210
+ expect ( analyzer . commentsAbove ( CURRENT_URI , 36 ) ) . toEqual ( 'doc for func_three' )
211
+ } )
203
212
204
- // if there is a line break in the comments
205
- // it should not include the above comment
206
- expect ( analyzer . commentsAbove ( CURRENT_URI , 36 ) ) . not . toMatch ( 'this is not included' )
213
+ it ( 'returns null if no comment found' , ( ) => {
214
+ analyzer . analyze ( CURRENT_URI , FIXTURES . COMMENT_DOC )
215
+ expect ( analyzer . commentsAbove ( CURRENT_URI , 45 ) ) . toEqual ( null )
216
+ } )
217
+
218
+ it ( 'works for variables' , ( ) => {
219
+ analyzer . analyze ( CURRENT_URI , FIXTURES . COMMENT_DOC )
220
+ expect ( analyzer . commentsAbove ( CURRENT_URI , 42 ) ) . toEqual ( 'works for variables' )
207
221
} )
208
222
} )
209
223
0 commit comments