@@ -421,8 +421,7 @@ namespace FourSlash {
421421 }
422422
423423 private raiseError ( message : string ) {
424- message = this . messageAtLastKnownMarker ( message ) ;
425- throw new Error ( message ) ;
424+ throw new Error ( this . messageAtLastKnownMarker ( message ) ) ;
426425 }
427426
428427 private messageAtLastKnownMarker ( message : string ) {
@@ -720,6 +719,27 @@ namespace FourSlash {
720719 }
721720 }
722721
722+ public verifyCompletionsAt ( markerName : string , expected : string [ ] ) {
723+ this . goToMarker ( markerName ) ;
724+
725+ const actualCompletions = this . getCompletionListAtCaret ( ) ;
726+ if ( ! actualCompletions ) {
727+ this . raiseError ( `No completions at position '${ this . currentCaretPosition } '.` ) ;
728+ }
729+
730+ const actual = actualCompletions . entries ;
731+
732+ if ( actual . length !== expected . length ) {
733+ this . raiseError ( `Expected ${ expected . length } completions, got ${ actual . map ( a => a . name ) } .` ) ;
734+ }
735+
736+ ts . zipWith ( actual , expected , ( completion , expectedCompletion , index ) => {
737+ if ( completion . name !== expectedCompletion ) {
738+ this . raiseError ( `Expected completion at index ${ index } to be ${ expectedCompletion } , got ${ completion . name } ` ) ;
739+ }
740+ } ) ;
741+ }
742+
723743 public verifyCompletionListContains ( symbol : string , text ?: string , documentation ?: string , kind ?: string , spanIndex ?: number ) {
724744 const completions = this . getCompletionListAtCaret ( ) ;
725745 if ( completions ) {
@@ -3162,6 +3182,10 @@ namespace FourSlashInterface {
31623182 super ( state ) ;
31633183 }
31643184
3185+ public completionsAt ( markerName : string , completions : string [ ] ) {
3186+ this . state . verifyCompletionsAt ( markerName , completions ) ;
3187+ }
3188+
31653189 public quickInfoIs ( expectedText : string , expectedDocumentation ?: string ) {
31663190 this . state . verifyQuickInfoString ( expectedText , expectedDocumentation ) ;
31673191 }
0 commit comments