-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextension.test.ts
48 lines (39 loc) · 1.46 KB
/
extension.test.ts
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
41
42
43
44
45
46
47
48
import * as assert from 'assert';
import { afterEach, beforeEach } from 'mocha';
import * as path from 'path';
import * as sinon from 'sinon';
// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode';
// import * as myExtension from '../extension';
suite('Extension Test Suite', () => {
let sandbox: sinon.SinonSandbox;
beforeEach(() => {
sandbox = sinon.createSandbox();
});
afterEach(() => {
sandbox.restore();
});
suite('`extension.helloWorld` command', () => {
test('shows a notification', async () => {
const spy = sandbox.stub(vscode.window, 'showInformationMessage');
await vscode.commands.executeCommand('extension.helloWorld');
assert(spy.calledWith('Hello, Angular!'));
});
});
suite('on hover', () => {
test('shows the template content when hovering over `templateUrl`', async () => {
const filePath = path.resolve(
__dirname, '../../../fixtures/simple-component/simple.component.ts');
const [hover] = await vscode.commands.executeCommand(
'vscode.executeHoverProvider',
vscode.Uri.file(filePath),
new vscode.Position(4, 20),
) as vscode.Hover[];
const hoverContents = (hover.contents[0] as vscode.MarkdownString).value;
assert.strictEqual(
hoverContents,
'```html\n<div class="simple">\n This is really simple.\n</div>\n\n```\n');
});
});
});