import * as vscode from 'vscode' ; import * as assert from 'assert' ; import { getDocUri , activate } from './helper' ; suite ( 'Should do completion' , ( ) => { const docUri = getDocUri ( 'completion.txt' ) ; test ( 'Completes JS/TS in txt file' , async ( ) => { await testCompletion ( docUri , new vscode . Position ( 0 , 0 ) , { items : [ { label : 'JavaScript' , kind : vscode . CompletionItemKind . Text } , { label : 'TypeScript' , kind : vscode . CompletionItemKind . Text } ] } ) ; } ) ; } ) ; async function testCompletion ( docUri , position , expectedCompletionList ) { await activate ( docUri ) ; const actualCompletionList = ( await vscode . commands . executeCommand ( 'vscode.executeCompletionItemProvider' , docUri , position ) ) as vscode . CompletionList ; assert . ok ( actualCompletionList . items . length >= 2 ) ; expectedCompletionList . items . forEach ( ( expectedItem , i ) => { const actualItem = actualCompletionList . items [ i ] ; assert . equal ( actualItem . label , expectedItem . label ) ; assert . equal ( actualItem . kind , expectedItem . kind ) ; } ) ; }