Skip to content

Commit 78900c7

Browse files
committed
test: completion integration test
1 parent 99ae57a commit 78900c7

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

integration-test/completion.test.ts

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import * as vscode from 'vscode'
2+
import { Document } from './document'
3+
import assert from 'assert'
4+
import { toPosition } from './helper'
5+
6+
suite('Completion', () => {
7+
test('kind equal completion', async () => {
8+
await testCompletion('kind_equal.sksl', toPosition(0, 8), [
9+
{
10+
label: 'blender',
11+
kind: vscode.CompletionItemKind.Text,
12+
},
13+
{
14+
label: 'colorfilter',
15+
kind: vscode.CompletionItemKind.Text,
16+
},
17+
{
18+
label: 'meshfrag',
19+
kind: vscode.CompletionItemKind.Text,
20+
},
21+
{
22+
label: 'meshvert',
23+
kind: vscode.CompletionItemKind.Text,
24+
},
25+
{
26+
label: 'shader',
27+
kind: vscode.CompletionItemKind.Text,
28+
},
29+
])
30+
})
31+
})
32+
33+
async function testCompletion(name: string, position: vscode.Position, expected: vscode.CompletionItem[]) {
34+
const doc = await Document.create(name)
35+
const actual = (
36+
(await vscode.commands.executeCommand(
37+
'vscode.executeCompletionItemProvider',
38+
doc.doc.uri,
39+
position,
40+
)) as vscode.CompletionList
41+
).items
42+
assert.equal(actual.length, expected.length)
43+
expected.forEach((expected_i, i) => {
44+
const actual_i = actual[i]
45+
assert.equal(actual_i.label, expected_i.label)
46+
assert.deepEqual(actual_i.kind, expected_i.kind)
47+
})
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// kind=
2+
void main() {}

integration-test/helper.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import * as vscode from 'vscode'
22

3+
export function toPosition(line: number, char: number) {
4+
return new vscode.Position(line, char)
5+
}
6+
37
export function toRange(sLine: number, sChar: number, eLine: number, eChar: number) {
48
const start = new vscode.Position(sLine, sChar)
59
const end = new vscode.Position(eLine, eChar)

0 commit comments

Comments
 (0)