Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add additional tests for #1314 #1318

Merged
merged 1 commit into from
Oct 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/test/definitions/parallel.test.ts
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');
});
});