Skip to content

Commit

Permalink
More completion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
neild3r committed Mar 27, 2017
1 parent bc9a9fa commit 80d9a91
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
9 changes: 7 additions & 2 deletions test/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ suite("Completion tests", () => {
map.forEach(testData => {
test("Completion: "+ testData.name, () => {
let pos:Position = testPositions[testData.key];
let result:ProviderResult<CompletionItem[]> = completions.provideCompletionItems(
let result:any = completions.provideCompletionItems(
document,
document.lineAt(pos.line+1).range.end,
new CancellationTokenSource().token
);

assert.equal(testData.tag, result[0].label);
let matched:Array<string> = [];
result.forEach(data => {
matched.push(data.label);
});

assert.deepEqual(testData.result, matched);
});
});
});
10 changes: 10 additions & 0 deletions test/fixtures/completions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@

////=> package
* @pack

////=> var
* @va

////=> nothing
* &

////=> function
/**
protected $name;
32 changes: 29 additions & 3 deletions test/fixtures/completions.php.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,42 @@
{
"key": "param",
"name": "Param tag",
"tag": "@param"
"result": [
"@param"
]
},
{
"key": "return",
"name": "Return tag",
"tag": "@return"
"result": [
"@return"
]
},
{
"key": "package",
"name": "Package tag",
"tag": "@package"
"result": [
"@package"
]
},
{
"key": "var",
"name": "Var tag",
"result": [
"@var"
]
},
{
"key": "nothing",
"name": "Nothing",
"result": [
]
},
{
"key": "function",
"name": "Function trigger",
"result": [
"/**"
]
}
]

0 comments on commit 80d9a91

Please sign in to comment.