forked from neild3r/vscode-php-docblocker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompletions.test.ts
40 lines (34 loc) · 1.3 KB
/
completions.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
import * as assert from 'assert';
import {TextEditor, TextDocument, CancellationTokenSource, CancellationToken, Position, ProviderResult, CompletionItem} from 'vscode';
import Helper from './helpers';
import Completions from '../src/completions';
suite("Completion tests", () => {
let editor:TextEditor;
let document:TextDocument;
let testPositions:any = {};
let completions = new Completions();
let map = Helper.getFixtureMap('completions.php.json');
suiteSetup(function(done) {
Helper.loadFixture('completions.php', (edit:TextEditor, doc:TextDocument) => {
editor = edit;
document = doc;
testPositions = Helper.getFixturePositions(document);
done();
});
});
map.forEach(testData => {
test("Completion: "+ testData.name, () => {
let pos:Position = testPositions[testData.key];
let result:any = completions.provideCompletionItems(
document,
document.lineAt(pos.line+1).range.end,
new CancellationTokenSource().token
);
let matched:Array<string> = [];
result.forEach(data => {
matched.push(data.label);
});
assert.deepEqual(testData.result, matched);
});
});
});