|
| 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 | +} |
0 commit comments