/* -------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ import * as vscode from 'vscode'; import * as assert from 'assert'; import { getDocUri, activate } from './helper'; suite('Should do completion', () => { const docUri = getDocUri('mainTest.pl'); // Unfortunately, this test does not work yet test('Test autocompletion', async () => { await testCompletion(docUri, new vscode.Position(29, 23), { items: [ { label: '$my_scalar', kind: vscode.CompletionItemKind.Variable }, ] }); }); }); async function testCompletion( docUri: vscode.Uri, position: vscode.Position, expectedCompletionList: vscode.CompletionList ) { await activate(docUri); // Executing the command `vscode.executeCompletionItemProvider` to simulate triggering completion const actualCompletionList = (await vscode.commands.executeCommand( 'vscode.executeCompletionItemProvider', docUri, position )) as vscode.CompletionList; assert.ok(actualCompletionList.items.length == 1); expectedCompletionList.items.forEach((expectedItem, i) => { const actualItem = actualCompletionList.items[i]; assert.equal(actualItem.label, expectedItem.label); assert.equal(actualItem.kind, expectedItem.kind); }); }