Skip to content

Commit 5c321a8

Browse files
committed
clean up option test
1 parent 958f328 commit 5c321a8

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

test/unitTests/options.test.ts

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { should, expect } from 'chai';
77
import { Options } from '../../src/omnisharp/options';
8-
import { getWorkspaceConfiguration, getVSCodeWithConfig } from './testAssets/Fakes';
8+
import { getVSCodeWithConfig, updateConfig } from './testAssets/Fakes';
99

1010
suite("Options tests", () => {
1111
suiteSetup(() => should());
@@ -31,42 +31,38 @@ suite("Options tests", () => {
3131

3232
test('BACK-COMPAT: "omnisharp.loggingLevel": "verbose" == "omnisharp.loggingLevel": "debug"', () =>
3333
{
34-
const omnisharpConfig = getWorkspaceConfiguration();
35-
omnisharpConfig.update('loggingLevel', "verbose");
36-
const vscode = getVSCodeWithConfig(omnisharpConfig);
34+
const vscode = getVSCodeWithConfig();
35+
updateConfig(vscode, 'omnisharp', 'loggingLevel', "verbose");
3736

3837
const options = Options.Read(vscode);
3938

4039
options.loggingLevel.should.equal("debug");
4140
});
4241

4342
test('BACK-COMPAT: "omnisharp.useMono": true == "omnisharp.useGlobalMono": "always"', () =>
44-
{
45-
const omnisharpConfig = getWorkspaceConfiguration();
46-
omnisharpConfig.update('useMono', true);
47-
const vscode = getVSCodeWithConfig(omnisharpConfig);
48-
43+
{
44+
const vscode = getVSCodeWithConfig();
45+
updateConfig(vscode, 'omnisharp', 'useMono', true);
46+
4947
const options = Options.Read(vscode);
5048

5149
options.useGlobalMono.should.equal("always");
5250
});
5351

5452
test('BACK-COMPAT: "omnisharp.useMono": false == "omnisharp.useGlobalMono": "auto"', () =>
5553
{
56-
const omnisharpConfig = getWorkspaceConfiguration();
57-
omnisharpConfig.update('useMono', false);
58-
const vscode = getVSCodeWithConfig(omnisharpConfig);
59-
54+
const vscode = getVSCodeWithConfig();
55+
updateConfig(vscode, 'omnisharp', 'useMono', false);
56+
6057
const options = Options.Read(vscode);
6158

6259
options.useGlobalMono.should.equal("auto");
6360
});
6461

6562
test('BACK-COMPAT: "csharp.omnisharpUsesMono": true == "omnisharp.useGlobalMono": "always"', () =>
6663
{
67-
const csharpConfig = getWorkspaceConfiguration();
68-
csharpConfig.update('omnisharpUsesMono', true);
69-
const vscode = getVSCodeWithConfig(undefined, csharpConfig);
64+
const vscode = getVSCodeWithConfig();
65+
updateConfig(vscode, 'csharp', 'omnisharpUsesMono', true);
7066

7167
const options = Options.Read(vscode);
7268

@@ -75,9 +71,8 @@ suite("Options tests", () => {
7571

7672
test('BACK-COMPAT: "csharp.omnisharpUsesMono": false == "omnisharp.useGlobalMono": "auto"', () =>
7773
{
78-
const csharpConfig = getWorkspaceConfiguration();
79-
csharpConfig.update('omnisharpUsesMono', false);
80-
const vscode = getVSCodeWithConfig(undefined, csharpConfig);
74+
const vscode = getVSCodeWithConfig();
75+
updateConfig(vscode, 'csharp', 'omnisharpUsesMono', false);
8176

8277
const options = Options.Read(vscode);
8378

@@ -86,9 +81,8 @@ suite("Options tests", () => {
8681

8782
test('BACK-COMPAT: "csharp.omnisharp" is used if it is set and "omnisharp.path" is not', () =>
8883
{
89-
const csharpConfig = getWorkspaceConfiguration();
90-
csharpConfig.update('omnisharp', 'OldPath');
91-
const vscode = getVSCodeWithConfig(undefined, csharpConfig);
84+
const vscode = getVSCodeWithConfig();
85+
updateConfig(vscode, 'csharp', 'omnisharp', 'OldPath');
9286

9387
const options = Options.Read(vscode);
9488

@@ -97,11 +91,9 @@ suite("Options tests", () => {
9791

9892
test('BACK-COMPAT: "csharp.omnisharp" is not used if "omnisharp.path" is set', () =>
9993
{
100-
const omnisharpConfig = getWorkspaceConfiguration();
101-
omnisharpConfig.update('path', 'NewPath');
102-
const csharpConfig = getWorkspaceConfiguration();
103-
csharpConfig.update('omnisharp', 'OldPath');
104-
const vscode = getVSCodeWithConfig(omnisharpConfig, csharpConfig);
94+
const vscode = getVSCodeWithConfig();
95+
updateConfig(vscode, 'omnisharp', 'path', 'NewPath');
96+
updateConfig(vscode, 'csharp', 'omnisharp', 'OldPath');
10597

10698
const options = Options.Read(vscode);
10799

0 commit comments

Comments
 (0)