diff --git a/src/test/definitions/parallel.test.ts b/src/test/definitions/parallel.test.ts new file mode 100644 index 000000000000..f70edb4a9910 --- /dev/null +++ b/src/test/definitions/parallel.test.ts @@ -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.executeHoverProvider', textDocument.uri, position); + const codeDef = await vscode.commands.executeCommand('vscode.executeDefinitionProvider', textDocument.uri, position); + position = new vscode.Position(3, 10); + const list = await vscode.commands.executeCommand('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'); + }); +});