Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/test/vscode-node/configurations.test.ts
13399 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
import * as assert from 'assert';
6
import { BaseConfig, Config, ConfigKey } from '../../../platform/configuration/common/configurationService';
7
import { ConfigurationServiceImpl } from '../../../platform/configuration/vscode/configurationServiceImpl';
8
import { Event } from '../../../util/vs/base/common/event';
9
10
class TestConfigurationServiceImpl extends ConfigurationServiceImpl {
11
12
public getDefinedDefaultValue<T>(key: BaseConfig<T>): T {
13
return key.defaultValue;
14
}
15
16
}
17
18
suite('Configuration Defaults', () => {
19
20
let testObject: TestConfigurationServiceImpl;
21
22
setup(() => {
23
testObject = new TestConfigurationServiceImpl({
24
_serviceBrand: undefined,
25
copilotToken: undefined,
26
onDidStoreUpdate: Event.None
27
});
28
});
29
30
teardown(() => testObject.dispose());
31
32
test('default values of all advanced settings should match default values', () => {
33
const advancedSettings = Object.values(ConfigKey.Advanced) as Config<unknown>[];
34
35
for (const setting of advancedSettings) {
36
const actual = testObject.getConfig<unknown>(setting);
37
const expected = testObject.getDefinedDefaultValue(setting);
38
assert.deepStrictEqual(actual, expected, `Default value for ${setting.fullyQualifiedId} did not match`);
39
}
40
41
});
42
43
test('default values of all internal settings', () => {
44
const internalSettings = Object.values(ConfigKey.TeamInternal) as Config<unknown>[];
45
46
for (const setting of internalSettings) {
47
const actual = testObject.getConfig<unknown>(setting);
48
const expected = testObject.getDefinedDefaultValue(setting);
49
assert.deepStrictEqual(actual, expected, `Default value for ${setting.fullyQualifiedId} did not match`);
50
}
51
});
52
53
});
54