diff options
author | bscan <10503608+bscan@users.noreply.github.com> | 2022-01-17 22:27:13 -0500 |
---|---|---|
committer | bscan <10503608+bscan@users.noreply.github.com> | 2022-01-17 22:27:13 -0500 |
commit | fa03b409a799cd540bc07e2d466cb6cbf790baab (patch) | |
tree | b85dfdd2f76faf33175dc1b9d67194883ed19122 /client/src/test/completion.test.ts | |
parent | 7e7a4e52d485afba9931ea7013cf05bea272b8c7 (diff) | |
download | PerlNavigator-fa03b409a799cd540bc07e2d466cb6cbf790baab.zip |
Initial commit
Diffstat (limited to 'client/src/test/completion.test.ts')
-rw-r--r-- | client/src/test/completion.test.ts | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/client/src/test/completion.test.ts b/client/src/test/completion.test.ts new file mode 100644 index 0000000..f355078 --- /dev/null +++ b/client/src/test/completion.test.ts @@ -0,0 +1,43 @@ +/* -------------------------------------------------------------------------------------------- + * 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('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: 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 >= 2); + expectedCompletionList.items.forEach((expectedItem, i) => { + const actualItem = actualCompletionList.items[i]; + assert.equal(actualItem.label, expectedItem.label); + assert.equal(actualItem.kind, expectedItem.kind); + }); +} |