-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
completion.test.ts
48 lines (40 loc) · 1.59 KB
/
completion.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import * as assert from 'assert'
import { getDocUri, activate } from './helper'
import * as vscode from 'vscode'
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.strictEqual(
actualCompletionList.items.length,
expectedCompletionList.items.length,
)
expectedCompletionList.items.forEach((expectedItem, i) => {
const actualItem = actualCompletionList.items[i]
assert.strictEqual(actualItem.label, expectedItem.label)
assert.strictEqual(actualItem.kind, expectedItem.kind)
})
}
describe('Should do completion', () => {
const docUri = getDocUri('completion.txt')
it('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 },
],
})
})
})