-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add additional tests for #1314 (#1318)
- Loading branch information
1 parent
792b022
commit f281674
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import * as assert from 'assert'; | ||
import { EOL } from 'os'; | ||
import * as vscode from 'vscode'; | ||
import * as path from 'path'; | ||
import { initialize, closeActiveWindows } from '../initialize'; | ||
import { normalizeMarkedString } from '../textUtils'; | ||
|
||
const autoCompPath = path.join(__dirname, '..', '..', '..', 'src', 'test', 'pythonFiles', 'autocomp'); | ||
const fileOne = path.join(autoCompPath, 'one.py'); | ||
|
||
suite('Code, Hover Definition and Intellisense', () => { | ||
suiteSetup(() => initialize()); | ||
suiteTeardown(() => closeActiveWindows()); | ||
teardown(() => closeActiveWindows()); | ||
|
||
test('All three together', async () => { | ||
const textDocument = await vscode.workspace.openTextDocument(fileOne); | ||
const editor = await vscode.window.showTextDocument(textDocument); | ||
|
||
let position = new vscode.Position(30, 5); | ||
const hoverDef = await vscode.commands.executeCommand<vscode.Hover[]>('vscode.executeHoverProvider', textDocument.uri, position); | ||
const codeDef = await vscode.commands.executeCommand<vscode.Location[]>('vscode.executeDefinitionProvider', textDocument.uri, position); | ||
position = new vscode.Position(3, 10); | ||
const list = await vscode.commands.executeCommand<vscode.CompletionList>('vscode.executeCompletionItemProvider', textDocument.uri, position); | ||
|
||
assert.equal(list.items.filter(item => item.label === 'api_version').length, 1, 'api_version not found'); | ||
|
||
assert.equal(codeDef.length, 1, 'Definition length is incorrect'); | ||
assert.equal(codeDef[0].uri.fsPath, fileOne, 'Incorrect file'); | ||
assert.equal(`${codeDef[0].range.start.line},${codeDef[0].range.start.character}`, '17,4', 'Start position is incorrect'); | ||
assert.equal(`${codeDef[0].range.end.line},${codeDef[0].range.end.character}`, '21,11', 'End position is incorrect'); | ||
|
||
assert.equal(hoverDef.length, 1, 'Definition length is incorrect'); | ||
assert.equal(`${hoverDef[0].range.start.line},${hoverDef[0].range.start.character}`, '30,4', 'Start position is incorrect'); | ||
assert.equal(`${hoverDef[0].range.end.line},${hoverDef[0].range.end.character}`, '30,11', 'End position is incorrect'); | ||
assert.equal(hoverDef[0].contents.length, 1, 'Invalid content items'); | ||
const expectedContent = '```python' + EOL + 'def method1()' + EOL + '```' + EOL + 'This is method1'; | ||
assert.equal(normalizeMarkedString(hoverDef[0].contents[0]), expectedContent, 'function signature incorrect'); | ||
}); | ||
}); |