@@ -80,7 +80,10 @@ const getCompletionsAtPosition = (pos: number, fileName = entrypoint) => {
80
80
return {
81
81
...result ,
82
82
entries : result . completions . entries ,
83
- entriesSorted : _ . sortBy ( result . completions . entries , ( { sortText } ) => sortText ) ,
83
+ /** Can be used in snapshots */
84
+ entriesSorted : _ . sortBy ( result . completions . entries , ( { sortText } ) => sortText )
85
+ . map ( ( { sortText, ...rest } ) => rest )
86
+ . map ( entry => Object . fromEntries ( Object . entries ( entry ) . filter ( ( [ , value ] ) => value !== undefined ) ) ) as ts . CompletionEntry [ ] ,
84
87
entryNames : result . completions . entries . map ( ( { name } ) => name ) ,
85
88
}
86
89
}
@@ -261,6 +264,7 @@ test('Switch Case Exclude Covered', () => {
261
264
test ( 'Object Literal Completions' , ( ) => {
262
265
const [ _positivePositions , _negativePositions , numPositions ] = fileContentsSpecialPositions ( /* ts */ `
263
266
interface Options {
267
+ usedOption
264
268
mood?: 'happy' | 'sad'
265
269
callback?()
266
270
additionalOptions?: {
@@ -271,70 +275,64 @@ test('Object Literal Completions', () => {
271
275
272
276
const makeDay = (options: Options) => {}
273
277
makeDay({
278
+ usedOption,
274
279
/*1*/
275
280
})
276
281
` )
277
282
const { entriesSorted } = getCompletionsAtPosition ( numPositions [ 1 ] ! ) ?? { }
278
283
// todo resolve sorting problem + add tests with other keepOriginal (it was tested manually)
279
- expect ( entriesSorted ?. map ( entry => Object . fromEntries ( Object . entries ( entry ) . filter ( ( [ , value ] ) => value !== undefined ) ) ) ) . toMatchInlineSnapshot ( `
284
+ for ( const entry of entriesSorted ?? [ ] ) {
285
+ entry . insertText = entry . insertText ?. replaceAll ( '\n' , '\\n' )
286
+ }
287
+ expect ( entriesSorted ) . toMatchInlineSnapshot ( `
280
288
[
281
289
{
282
290
"insertText": "plugins",
283
291
"isSnippet": true,
284
292
"kind": "property",
285
293
"kindModifiers": "",
286
294
"name": "plugins",
287
- "sortText": "110000",
288
295
},
289
296
{
290
- "insertText": "plugins: [
291
- $1
292
- ],$0",
297
+ "insertText": "plugins: [\\\\n $1\\\\n],$0",
293
298
"isSnippet": true,
294
299
"kind": "property",
295
300
"kindModifiers": "",
296
301
"labelDetails": {
297
302
"detail": ": [],",
298
303
},
299
304
"name": "plugins",
300
- "sortText": "110001",
301
305
},
302
306
{
303
307
"insertText": "additionalOptions",
304
308
"isSnippet": true,
305
309
"kind": "property",
306
310
"kindModifiers": "optional",
307
311
"name": "additionalOptions",
308
- "sortText": "120002",
309
312
},
310
313
{
311
- "insertText": "additionalOptions: {
312
- $1
313
- },$0",
314
+ "insertText": "additionalOptions: {\\\\n $1\\\\n},$0",
314
315
"isSnippet": true,
315
316
"kind": "property",
316
317
"kindModifiers": "optional",
317
318
"labelDetails": {
318
319
"detail": ": {},",
319
320
},
320
321
"name": "additionalOptions",
321
- "sortText": "120003",
322
322
},
323
323
{
324
324
"insertText": "callback",
325
325
"isSnippet": true,
326
326
"kind": "method",
327
327
"kindModifiers": "optional",
328
328
"name": "callback",
329
- "sortText": "120004",
330
329
},
331
330
{
332
331
"insertText": "mood",
333
332
"isSnippet": true,
334
333
"kind": "property",
335
334
"kindModifiers": "optional",
336
335
"name": "mood",
337
- "sortText": "120005",
338
336
},
339
337
{
340
338
"insertText": "mood: \\"$1\\",$0",
@@ -345,7 +343,6 @@ test('Object Literal Completions', () => {
345
343
"detail": ": \\"\\",",
346
344
},
347
345
"name": "mood",
348
- "sortText": "120006",
349
346
},
350
347
]
351
348
` )
0 commit comments