forked from PowerShell/vscode-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.test.ts
49 lines (40 loc) · 2.03 KB
/
settings.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
49
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import * as assert from "assert";
import * as vscode from "vscode";
import Settings = require("../../src/settings");
describe("Settings module", function () {
it("Loads without error", function () {
assert.doesNotThrow(Settings.load);
});
it("Updates correctly with 'then' syntax", async function () {
Settings.change("helpCompletion", "BlockComment", false).then(() =>
assert.strictEqual(Settings.load().helpCompletion, "BlockComment"));
});
it("Updates correctly with 'async/await' syntax", async function () {
await Settings.change("helpCompletion", "LineComment", false);
assert.strictEqual(Settings.load().helpCompletion, "LineComment");
});
describe("User-only settings", async function () {
const psExeDetails = {
"My PowerShell": "dummyPath",
};
it("Throws when updating at workspace-level", async function () {
assert.rejects(async () => await Settings.change("powerShellAdditionalExePaths", psExeDetails, false /* workspace-level */));
});
it("Doesn't throw when updating at user-level", async function () {
await Settings.change("powerShellAdditionalExePaths", psExeDetails, true /* user-level */);
const result = Settings.load().powerShellAdditionalExePaths["My PowerShell"];
assert.notStrictEqual(result, undefined);
assert.strictEqual(result, psExeDetails["My PowerShell"]);
});
});
it("Gets the effective configuration target", async function () {
await Settings.change("helpCompletion", "LineComment", false);
let target = await Settings.getEffectiveConfigurationTarget("helpCompletion");
assert.strictEqual(target, vscode.ConfigurationTarget.Workspace);
await Settings.change("helpCompletion", undefined, false);
target = await Settings.getEffectiveConfigurationTarget("helpCompletion");
assert.strictEqual(target, null);
});
});