Skip to content

Commit 0c2c007

Browse files
committed
Improve ISE compatibility tests
Save and restore the user's theme, which was annoying when running the tests via Code's debugger. Don't use the default theme "Dark+" so that the setting is actually propogated.
1 parent 897d4c5 commit 0c2c007

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

test/features/ISECompatibility.test.ts

+22-5
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,29 @@
33

44
import * as assert from "assert";
55
import * as vscode from "vscode";
6-
import { suiteSetup, setup, teardown } from "mocha";
6+
import { suiteSetup, setup, suiteTeardown, teardown } from "mocha";
77
import { ISECompatibilityFeature } from "../../src/features/ISECompatibility";
88
import utils = require("../utils");
99

1010
suite("ISECompatibility feature", () => {
11-
suiteSetup(utils.ensureExtensionIsActivated);
11+
let currentTheme: string;
12+
13+
suiteSetup(async () => {
14+
// Save user's current theme.
15+
currentTheme = await vscode.workspace.getConfiguration("workbench").get("colorTheme");
16+
await utils.ensureExtensionIsActivated();
17+
});
18+
1219
setup(async () => { await vscode.commands.executeCommand("PowerShell.EnableISEMode"); });
20+
1321
teardown(async () => { await vscode.commands.executeCommand("PowerShell.DisableISEMode"); });
1422

23+
suiteTeardown(async () => {
24+
// Reset user's current theme.
25+
await vscode.workspace.getConfiguration("workbench").update("colorTheme", currentTheme, true);
26+
assert.strictEqual(vscode.workspace.getConfiguration("workbench").get("colorTheme"), currentTheme);
27+
});
28+
1529
test("It sets ISE Settings", async () => {
1630
for (const iseSetting of ISECompatibilityFeature.settings) {
1731
const currently = vscode.workspace.getConfiguration(iseSetting.path).get(iseSetting.name);
@@ -31,15 +45,18 @@ suite("ISECompatibility feature", () => {
3145
}
3246
}).timeout(10000);
3347

34-
test("It leaves Theme after being changed after enabling ISE Mode", async () => {
48+
test("It doesn't change theme when disabled if theme was manually changed after being enabled", async () => {
3549
assert.strictEqual(vscode.workspace.getConfiguration("workbench").get("colorTheme"), "PowerShell ISE");
3650

37-
await vscode.workspace.getConfiguration("workbench").update("colorTheme", "Dark+", true);
51+
// "Manually" change theme after enabling ISE mode. Use a built-in theme but not the default.
52+
await vscode.workspace.getConfiguration("workbench").update("colorTheme", "Monokai", true);
53+
assert.strictEqual(vscode.workspace.getConfiguration("workbench").get("colorTheme"), "Monokai");
54+
3855
await vscode.commands.executeCommand("PowerShell.DisableISEMode");
3956
for (const iseSetting of ISECompatibilityFeature.settings) {
4057
const currently = vscode.workspace.getConfiguration(iseSetting.path).get(iseSetting.name);
4158
assert.notStrictEqual(currently, iseSetting.value);
4259
}
43-
assert.strictEqual(vscode.workspace.getConfiguration("workbench").get("colorTheme"), "Dark+");
60+
assert.strictEqual(vscode.workspace.getConfiguration("workbench").get("colorTheme"), "Monokai");
4461
}).timeout(10000);
4562
});

0 commit comments

Comments
 (0)