@@ -130,7 +130,7 @@ describe('server', () => {
130
130
} )
131
131
} )
132
132
133
- it ( 'responds to onCompletion when word is found' , async ( ) => {
133
+ it ( 'responds to onCompletion with filtered list when word is found' , async ( ) => {
134
134
const { connection, server } = await initializeServer ( )
135
135
server . register ( connection )
136
136
@@ -142,18 +142,61 @@ describe('server', () => {
142
142
uri : FIXTURE_URI . INSTALL ,
143
143
} ,
144
144
position : {
145
+ // rm
145
146
line : 25 ,
146
147
character : 5 ,
147
148
} ,
148
149
} ,
149
150
{ } as any ,
150
151
)
151
152
153
+ expect ( result ) . toMatchInlineSnapshot ( `
154
+ Array [
155
+ Object {
156
+ "data": Object {
157
+ "name": "rm",
158
+ "type": "executable",
159
+ },
160
+ "kind": 12,
161
+ "label": "rm",
162
+ },
163
+ Object {
164
+ "data": Object {
165
+ "name": "rmdir",
166
+ "type": "executable",
167
+ },
168
+ "kind": 12,
169
+ "label": "rmdir",
170
+ },
171
+ ]
172
+ ` )
173
+ } )
174
+
175
+ it ( 'responds to onCompletion with entire list when no word is found' , async ( ) => {
176
+ const { connection, server } = await initializeServer ( )
177
+ server . register ( connection )
178
+
179
+ const onCompletion = connection . onCompletion . mock . calls [ 0 ] [ 0 ]
180
+
181
+ const result = await onCompletion (
182
+ {
183
+ textDocument : {
184
+ uri : FIXTURE_URI . INSTALL ,
185
+ } ,
186
+ position : {
187
+ // else
188
+ line : 24 ,
189
+ character : 5 ,
190
+ } ,
191
+ } ,
192
+ { } as any ,
193
+ )
194
+
152
195
// Entire list
153
- expect ( 'length' in result && result . length > 50 )
196
+ expect ( 'length' in result && result . length > 50 ) . toBe ( true )
154
197
} )
155
198
156
- it ( 'responds to onCompletion when no word is found ' , async ( ) => {
199
+ it ( 'responds to onCompletion with empty list when word is a comment ' , async ( ) => {
157
200
const { connection, server } = await initializeServer ( )
158
201
server . register ( connection )
159
202
@@ -165,14 +208,14 @@ describe('server', () => {
165
208
uri : FIXTURE_URI . INSTALL ,
166
209
} ,
167
210
position : {
211
+ // inside comment
168
212
line : 2 ,
169
213
character : 1 ,
170
214
} ,
171
215
} ,
172
216
{ } as any ,
173
217
)
174
218
175
- // Entire list
176
- expect ( 'length' in result && result . length > 50 )
219
+ expect ( result ) . toEqual ( [ ] )
177
220
} )
178
221
} )
0 commit comments