-
Notifications
You must be signed in to change notification settings - Fork 542
Expand file tree
/
Copy pathISECompatibility.test.ts
More file actions
150 lines (137 loc) · 5.46 KB
/
ISECompatibility.test.ts
File metadata and controls
150 lines (137 loc) · 5.46 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import * as assert from "assert";
import * as vscode from "vscode";
import { ISECompatibilityFeature } from "../../src/features/ISECompatibility";
import utils = require("../utils");
describe("ISE compatibility feature", function () {
let currentTheme: string | undefined;
async function enableISEMode(): Promise<void> {
await vscode.commands.executeCommand("PowerShell.EnableISEMode");
}
async function disableISEMode(): Promise<void> {
await vscode.commands.executeCommand("PowerShell.DisableISEMode");
}
async function toggleISEMode(): Promise<void> {
await vscode.commands.executeCommand("PowerShell.ToggleISEMode");
}
before(async function () {
// Save user's current theme.
currentTheme = await vscode.workspace
.getConfiguration("workbench")
.get("colorTheme");
await utils.ensureEditorServicesIsConnected();
});
after(async function () {
// Reset user's current theme.
await vscode.workspace
.getConfiguration("workbench")
.update("colorTheme", currentTheme, true);
assert.strictEqual(
vscode.workspace.getConfiguration("workbench").get("colorTheme"),
currentTheme,
);
});
describe("Enable ISE Mode updates expected settings", function () {
before(enableISEMode);
after(disableISEMode);
for (const iseSetting of ISECompatibilityFeature.settings) {
it(`Sets ${iseSetting.name} correctly`, function () {
const currently = vscode.workspace
.getConfiguration(iseSetting.path)
.get(iseSetting.name);
assert.strictEqual(currently, iseSetting.value);
});
}
});
describe("Disable ISE Mode reverts expected settings", function () {
before(enableISEMode);
before(disableISEMode);
after(disableISEMode);
for (const iseSetting of ISECompatibilityFeature.settings) {
it(`Reverts ${iseSetting.name} correctly`, function () {
const currently = vscode.workspace
.getConfiguration(iseSetting.path)
.get(iseSetting.name);
assert.notStrictEqual(currently, iseSetting.value);
});
}
});
describe("Toggle switches from enabled to disabled", function () {
before(enableISEMode);
before(toggleISEMode);
after(disableISEMode);
for (const iseSetting of ISECompatibilityFeature.settings) {
it(`Reverts ${iseSetting.name} correctly`, function () {
const currently = vscode.workspace
.getConfiguration(iseSetting.path)
.get(iseSetting.name);
assert.notStrictEqual(currently, iseSetting.value);
});
}
});
describe("Toggle switches from disabled to enabled", function () {
before(disableISEMode);
before(toggleISEMode);
after(disableISEMode);
for (const iseSetting of ISECompatibilityFeature.settings) {
it(`Sets ${iseSetting.name} correctly`, function () {
const currently = vscode.workspace
.getConfiguration(iseSetting.path)
.get(iseSetting.name);
assert.strictEqual(currently, iseSetting.value);
});
}
});
describe("Color theme interactions", function () {
beforeEach(enableISEMode);
function assertISESettings(): void {
for (const iseSetting of ISECompatibilityFeature.settings) {
const currently = vscode.workspace
.getConfiguration(iseSetting.path)
.get(iseSetting.name);
assert.notStrictEqual(currently, iseSetting.value);
}
}
it("Changes the theme back from PowerShell ISE", async function () {
// Change state to something that DisableISEMode will change
await vscode.workspace
.getConfiguration("workbench")
.update("colorTheme", "PowerShell ISE", true);
assert.strictEqual(
vscode.workspace
.getConfiguration("workbench")
.get("colorTheme"),
"PowerShell ISE",
);
await disableISEMode();
assertISESettings();
});
it("Doesn't change theme if it was manually changed", async function () {
assert.strictEqual(
vscode.workspace
.getConfiguration("workbench")
.get("colorTheme"),
"PowerShell ISE",
);
// "Manually" change theme after enabling ISE mode. Use a built-in theme but not the default.
await vscode.workspace
.getConfiguration("workbench")
.update("colorTheme", "Monokai", true);
assert.strictEqual(
vscode.workspace
.getConfiguration("workbench")
.get("colorTheme"),
"Monokai",
);
await disableISEMode();
assertISESettings();
assert.strictEqual(
vscode.workspace
.getConfiguration("workbench")
.get("colorTheme"),
"Monokai",
);
});
});
});