@@ -425,8 +425,7 @@ namespace FourSlash {
425425 }
426426
427427 private raiseError ( message : string ) {
428- message = this . messageAtLastKnownMarker ( message ) ;
429- throw new Error ( message ) ;
428+ throw new Error ( this . messageAtLastKnownMarker ( message ) ) ;
430429 }
431430
432431 private messageAtLastKnownMarker ( message : string ) {
@@ -723,6 +722,27 @@ namespace FourSlash {
723722 }
724723 }
725724
725+ public verifyCompletionsAt ( markerName : string , expected : string [ ] ) {
726+ this . goToMarker ( markerName ) ;
727+
728+ const actualCompletions = this . getCompletionListAtCaret ( ) ;
729+ if ( ! actualCompletions ) {
730+ this . raiseError ( `No completions at position '${ this . currentCaretPosition } '.` ) ;
731+ }
732+
733+ const actual = actualCompletions . entries ;
734+
735+ if ( actual . length !== expected . length ) {
736+ this . raiseError ( `Expected ${ expected . length } completions, got ${ actual . map ( a => a . name ) } .` ) ;
737+ }
738+
739+ ts . zipWith ( actual , expected , ( completion , expectedCompletion , index ) => {
740+ if ( completion . name !== expectedCompletion ) {
741+ this . raiseError ( `Expected completion at index ${ index } to be ${ expectedCompletion } , got ${ completion . name } ` ) ;
742+ }
743+ } ) ;
744+ }
745+
726746 public verifyCompletionListContains ( symbol : string , text ?: string , documentation ?: string , kind ?: string , spanIndex ?: number ) {
727747 const completions = this . getCompletionListAtCaret ( ) ;
728748 if ( completions ) {
@@ -3166,6 +3186,10 @@ namespace FourSlashInterface {
31663186 super ( state ) ;
31673187 }
31683188
3189+ public completionsAt ( markerName : string , completions : string [ ] ) {
3190+ this . state . verifyCompletionsAt ( markerName , completions ) ;
3191+ }
3192+
31693193 public quickInfoIs ( expectedText : string , expectedDocumentation ?: string ) {
31703194 this . state . verifyQuickInfoString ( expectedText , expectedDocumentation ) ;
31713195 }
0 commit comments