-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathextension.test.ts
More file actions
56 lines (44 loc) · 1.55 KB
/
extension.test.ts
File metadata and controls
56 lines (44 loc) · 1.55 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import * as assert from "assert";
import * as vscode from "vscode";
suite("Extension Test Suite", () => {
vscode.window.showInformationMessage("Start all tests.");
test("Extension should be present", () => {
assert.ok(vscode.extensions.getExtension("coder.coder-remote"));
});
test("Extension should activate", async () => {
const extension = vscode.extensions.getExtension("coder.coder-remote");
assert.ok(extension);
if (!extension.isActive) {
await extension.activate();
}
assert.ok(extension.isActive);
});
test("Extension should export activate function", async () => {
const extension = vscode.extensions.getExtension("coder.coder-remote");
assert.ok(extension);
await extension.activate();
// The extension doesn't export anything, which is fine
// The test was expecting exports.activate but the extension
// itself is the activate function
assert.ok(extension.isActive);
});
test("Commands should be registered", async () => {
const extension = vscode.extensions.getExtension("coder.coder-remote");
assert.ok(extension);
if (!extension.isActive) {
await extension.activate();
}
// Give a small delay for commands to register
await new Promise((resolve) => setTimeout(resolve, 100));
const commands = await vscode.commands.getCommands(true);
const coderCommands = commands.filter((cmd) => cmd.startsWith("coder."));
assert.ok(
coderCommands.length > 0,
"Should have registered Coder commands",
);
assert.ok(
coderCommands.includes("coder.login"),
"Should have coder.login command",
);
});
});