-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.test.ts
More file actions
63 lines (49 loc) · 2.19 KB
/
extension.test.ts
File metadata and controls
63 lines (49 loc) · 2.19 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
57
58
59
60
61
62
63
import * as assert from "assert";
import * as vscode from "vscode";
suite("Extension Test Suite", () => {
vscode.window.showInformationMessage("Start extension tests.");
test("Extension should be present", () => {
assert.ok(
vscode.extensions.getExtension("ahnafnafee.postscript-preview")
);
});
test("Extension should activate", async () => {
const ext = vscode.extensions.getExtension(
"ahnafnafee.postscript-preview"
);
assert.ok(ext, "Extension not found");
// Activate if not active
if (!ext.isActive) {
await ext.activate();
}
assert.strictEqual(ext.isActive, true);
});
test("Command should be registered", async () => {
const commands = await vscode.commands.getCommands(true);
assert.ok(commands.includes("postscript-preview.sidePreview"));
});
test("Preview command should execute without error", async () => {
// Ensure workspace is open
assert.ok(vscode.workspace.workspaceFolders, "No workspace is open");
const workspaceRoot = vscode.workspace.workspaceFolders[0].uri.fsPath;
const filePath = vscode.Uri.file(
workspaceRoot + "/examples/basic_shapes.ps"
);
const doc = await vscode.workspace.openTextDocument(filePath);
await vscode.window.showTextDocument(doc);
// Execute the command - validation fails if this throws
await vscode.commands.executeCommand("postscript-preview.sidePreview");
});
test("Preview command should execute with special characters in filename", async () => {
// Ensure workspace is open
assert.ok(vscode.workspace.workspaceFolders, "No workspace is open");
const workspaceRoot = vscode.workspace.workspaceFolders[0].uri.fsPath;
const filePath = vscode.Uri.file(
workspaceRoot + "/examples/test (example).ps"
);
const doc = await vscode.workspace.openTextDocument(filePath);
await vscode.window.showTextDocument(doc);
// Execute the command - validation fails if this throws
await vscode.commands.executeCommand("postscript-preview.sidePreview");
});
});