@@ -5,7 +5,7 @@ import { isGoodPositionMethodCompletion } from '../src/completions/isGoodPositio
55import { findChildContainingExactPosition , isTs5 } from '../src/utils'
66import handleCommand from '../src/specialCommands/handle'
77import constructMethodSnippet from '../src/constructMethodSnippet'
8- import { defaultConfigFunc , entrypoint , settingsOverride , sharedLanguageService } from './shared'
8+ import { currentTestingContext , defaultConfigFunc , entrypoint , settingsOverride , sharedLanguageService } from './shared'
99import { fileContentsSpecialPositions , fourslashLikeTester , getCompletionsAtPosition , overrideSettings } from './testing'
1010
1111const { languageService, languageServiceHost, updateProject, getCurrentFile } = sharedLanguageService
@@ -124,6 +124,12 @@ const compareMethodSnippetAgainstMarker = (inputMarkers: number[], marker: numbe
124124 expect ( Array . isArray ( expected ) ? methodSnippet : snippetToInsert , `At marker ${ marker } ` ) . toEqual ( expected )
125125}
126126
127+ const assertCompletionInsertText = ( marker : number , entryName : string | undefined , insertTextExpected : string ) => {
128+ const { entries } = getCompletionsAtPosition ( currentTestingContext . markers [ marker ] ! ) !
129+ const entry = entryName === undefined ? entries [ 0 ] : entries . find ( ( { name } ) => name === entryName )
130+ expect ( entry ?. insertText ) . toEqual ( insertTextExpected )
131+ }
132+
127133describe ( 'Method snippets' , ( ) => {
128134 test ( 'Misc' , ( ) => {
129135 const [ , _ , markers ] = fileContentsSpecialPositions ( /* ts */ `
@@ -286,6 +292,24 @@ describe('Method snippets', () => {
286292 compareMethodSnippetAgainstMarker ( markers , 1 , 'ambiguous' )
287293 compareMethodSnippetAgainstMarker ( markers , 2 , 'ambiguous' )
288294 } )
295+
296+ test ( 'methodSnippetsInsertText all' , ( ) => {
297+ overrideSettings ( {
298+ methodSnippetsInsertText : 'all' ,
299+ } )
300+ fileContentsSpecialPositions ( /* ts */ `
301+ const a = (a, b) => {}
302+ a/*1*/
303+
304+ class A {
305+ test() {
306+ test/*2*/
307+ }
308+ }
309+ ` )
310+ assertCompletionInsertText ( 1 , 'a' , 'a(${1:a}, ${2:b})' )
311+ assertCompletionInsertText ( 2 , 'test' , 'this.test()' )
312+ } )
289313} )
290314
291315test ( 'Emmet completion' , ( ) => {
0 commit comments