|
| 1 | +import * as vscode from 'vscode'; |
| 2 | +import { activateExtension, openTestFile } from './test-util'; |
| 3 | +import assert from 'assert'; |
| 4 | + |
| 5 | + |
| 6 | +suite('hover values', () => { |
| 7 | + let editor: vscode.TextEditor; |
| 8 | + |
| 9 | + const tc = async(pos: vscode.Position, expected: string) => { |
| 10 | + const result: vscode.Hover[] = await vscode.commands.executeCommand('vscode.executeHoverProvider', editor.document.uri, pos); |
| 11 | + assert.ok(result); |
| 12 | + assert.equal(result.length, 1); |
| 13 | + |
| 14 | + const hover = result[0].contents[0] as vscode.MarkdownString; |
| 15 | + assert.equal(hover.value, `**Inferred Value**\n\n${expected}`); |
| 16 | + }; |
| 17 | + |
| 18 | + suiteSetup(async() => { |
| 19 | + await activateExtension(); |
| 20 | + editor = await openTestFile('hover-values-example.R'); |
| 21 | + }); |
| 22 | + |
| 23 | + test.only('shows inferred value for variable', async() => { |
| 24 | + await tc(new vscode.Position(0, 1), '[2L, 2L]'); |
| 25 | + await tc(new vscode.Position(0, 5), '[2L, 2L]'); |
| 26 | + }); |
| 27 | + |
| 28 | + test.only('shows inferred value correctly in sequences', async() => { |
| 29 | + await tc(new vscode.Position(1, 5), '[3L, 3L]'); |
| 30 | + await tc(new vscode.Position(1, 7), '[40L, 40L]'); |
| 31 | + }); |
| 32 | + |
| 33 | + test.only('shows inferred value for dataframe', async() => { |
| 34 | + const df = `Dataframe Shape: |
| 35 | +| | | |
| 36 | +|----|----| |
| 37 | +| Rows: | [3, 3] | |
| 38 | +| Cols: | [2, 2] | |
| 39 | +
|
| 40 | +Known Columns: \`id\`, \`label\``; |
| 41 | + await tc(new vscode.Position(2, 1), df); |
| 42 | + }); |
| 43 | +}); |
| 44 | + |
0 commit comments