forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparallel.test.ts
More file actions
40 lines (33 loc) · 2.43 KB
/
parallel.test.ts
File metadata and controls
40 lines (33 loc) · 2.43 KB
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 { 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');
});
});