@@ -67,11 +67,22 @@ describe('server', () => {
67
67
{ } as any ,
68
68
)
69
69
70
- // if user hovers over a function name
71
- // the hover contents should contain
72
- // the comment above the function definition
73
- // see testing/fixtures/comment-doc-on-hover.sh
74
- const commentResult = await onHover (
70
+ expect ( result ) . toBeDefined ( )
71
+ expect ( result ) . toEqual ( {
72
+ contents : {
73
+ kind : 'markdown' ,
74
+ value : expect . stringContaining ( 'remove directories' ) ,
75
+ } ,
76
+ } )
77
+ } )
78
+
79
+ it ( 'responds to onHover with function documentation extracted from comments' , async ( ) => {
80
+ const { connection, server } = await initializeServer ( )
81
+ server . register ( connection )
82
+
83
+ const onHover = connection . onHover . mock . calls [ 0 ] [ 0 ]
84
+
85
+ const result = await onHover (
75
86
{
76
87
textDocument : {
77
88
uri : FIXTURE_URI . COMMENT_DOC ,
@@ -87,15 +98,8 @@ describe('server', () => {
87
98
88
99
expect ( result ) . toBeDefined ( )
89
100
expect ( result ) . toEqual ( {
90
- contents : {
91
- kind : 'markdown' ,
92
- value : expect . stringContaining ( 'remove directories' ) ,
93
- } ,
94
- } )
95
-
96
- expect ( commentResult ) . toBeDefined ( )
97
- expect ( commentResult ) . toEqual ( {
98
- contents : expect . stringContaining ( 'this function takes two arguments' ) ,
101
+ contents :
102
+ 'Function defined on line 8\n\nthis is a comment\ndescribing the function\nhello_world\nthis function takes two arguments' ,
99
103
} )
100
104
} )
101
105
0 commit comments