|
| 1 | +import { strict as assert } from "assert"; |
| 2 | +import * as vs from "vscode"; |
| 3 | +import { activate, helloWorldMainFile } from "../../helpers"; |
| 4 | + |
| 5 | +describe("toggle show TODOs", () => { |
| 6 | + const settingName = "showTodos"; |
| 7 | + let config: vs.WorkspaceConfiguration; |
| 8 | + |
| 9 | + function refresh(): void { |
| 10 | + config = vs.workspace.getConfiguration("dart"); |
| 11 | + } |
| 12 | + |
| 13 | + beforeEach(async () => { |
| 14 | + await activate(helloWorldMainFile); |
| 15 | + refresh(); |
| 16 | + // Clear overrides to start from a clean state. |
| 17 | + await config.update(settingName, undefined, vs.ConfigurationTarget.Global); |
| 18 | + await config.update(settingName, undefined, vs.ConfigurationTarget.Workspace); |
| 19 | + refresh(); |
| 20 | + }); |
| 21 | + |
| 22 | + // (mult-root) Workspaces are tested in the 'multi_root' tests. This test project is a single folder. |
| 23 | + |
| 24 | + it("toggles in User settings when not defined anywhere", async () => { |
| 25 | + // Default is true. |
| 26 | + refresh(); |
| 27 | + assert.strictEqual(config.get<boolean>(settingName), true); |
| 28 | + |
| 29 | + await vs.commands.executeCommand("dart.toggleShowTodos"); |
| 30 | + refresh(); |
| 31 | + assert.strictEqual(config.get<boolean>(settingName), false); |
| 32 | + assert.strictEqual(config.inspect(settingName)?.globalValue, false); |
| 33 | + assert.strictEqual(config.inspect(settingName)?.workspaceValue, undefined); |
| 34 | + |
| 35 | + await vs.commands.executeCommand("dart.toggleShowTodos"); |
| 36 | + refresh(); |
| 37 | + assert.strictEqual(config.get<boolean>(settingName), true); |
| 38 | + assert.strictEqual(config.inspect(settingName)?.globalValue, true); |
| 39 | + assert.strictEqual(config.inspect(settingName)?.workspaceValue, undefined); |
| 40 | + }); |
| 41 | + |
| 42 | + it("toggles in User settings when defined in User settings", async () => { |
| 43 | + await config.update(settingName, false, vs.ConfigurationTarget.Global); |
| 44 | + refresh(); |
| 45 | + assert.strictEqual(config.get<boolean>(settingName), false); |
| 46 | + |
| 47 | + await vs.commands.executeCommand("dart.toggleShowTodos"); |
| 48 | + refresh(); |
| 49 | + assert.strictEqual(config.get<boolean>(settingName), true); |
| 50 | + assert.strictEqual(config.inspect(settingName)?.globalValue, true); |
| 51 | + assert.strictEqual(config.inspect(settingName)?.workspaceValue, undefined); |
| 52 | + assert.strictEqual(config.inspect(settingName)?.workspaceFolderValue, undefined); |
| 53 | + |
| 54 | + await vs.commands.executeCommand("dart.toggleShowTodos"); |
| 55 | + refresh(); |
| 56 | + assert.strictEqual(config.get<boolean>(settingName), false); |
| 57 | + assert.strictEqual(config.inspect(settingName)?.globalValue, false); |
| 58 | + assert.strictEqual(config.inspect(settingName)?.workspaceValue, undefined); |
| 59 | + assert.strictEqual(config.inspect(settingName)?.workspaceFolderValue, undefined); |
| 60 | + }); |
| 61 | + |
| 62 | + it("toggles in Workspace (Folder) settings when defined in Folder settings (single-root workspace)", async () => { |
| 63 | + await config.update(settingName, false, vs.ConfigurationTarget.Workspace); |
| 64 | + refresh(); |
| 65 | + assert.strictEqual(config.get<boolean>(settingName), false); |
| 66 | + |
| 67 | + await vs.commands.executeCommand("dart.toggleShowTodos"); |
| 68 | + refresh(); |
| 69 | + assert.strictEqual(config.get<boolean>(settingName), true); |
| 70 | + assert.strictEqual(config.inspect(settingName)?.globalValue, undefined); |
| 71 | + assert.strictEqual(config.inspect(settingName)?.workspaceValue, true); |
| 72 | + |
| 73 | + await vs.commands.executeCommand("dart.toggleShowTodos"); |
| 74 | + refresh(); |
| 75 | + assert.strictEqual(config.get<boolean>(settingName), false); |
| 76 | + assert.strictEqual(config.inspect(settingName)?.globalValue, undefined); |
| 77 | + assert.strictEqual(config.inspect(settingName)?.workspaceValue, false); |
| 78 | + }); |
| 79 | +}); |
0 commit comments