Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/configuration/test/common/configurationModels.test.ts
3296 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 assert from 'assert';
6
import { ResourceMap } from '../../../../base/common/map.js';
7
import { join } from '../../../../base/common/path.js';
8
import { URI } from '../../../../base/common/uri.js';
9
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js';
10
import { Configuration, ConfigurationChangeEvent, ConfigurationModel, ConfigurationModelParser, mergeChanges } from '../../common/configurationModels.js';
11
import { IConfigurationRegistry, Extensions, ConfigurationScope } from '../../common/configurationRegistry.js';
12
import { NullLogService } from '../../../log/common/log.js';
13
import { Registry } from '../../../registry/common/platform.js';
14
import { WorkspaceFolder } from '../../../workspace/common/workspace.js';
15
import { Workspace } from '../../../workspace/test/common/testWorkspace.js';
16
17
suite('ConfigurationModelParser', () => {
18
19
ensureNoDisposablesAreLeakedInTestSuite();
20
21
suiteSetup(() => {
22
Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfiguration({
23
'id': 'ConfigurationModelParserTest',
24
'type': 'object',
25
'properties': {
26
'ConfigurationModelParserTest.windowSetting': {
27
'type': 'string',
28
'default': 'isSet',
29
}
30
}
31
});
32
});
33
34
test('parse configuration model with single override identifier', () => {
35
const testObject = new ConfigurationModelParser('', new NullLogService());
36
37
testObject.parse(JSON.stringify({ '[x]': { 'a': 1 } }));
38
39
assert.deepStrictEqual(JSON.stringify(testObject.configurationModel.overrides), JSON.stringify([{ identifiers: ['x'], keys: ['a'], contents: { 'a': 1 } }]));
40
});
41
42
test('parse configuration model with multiple override identifiers', () => {
43
const testObject = new ConfigurationModelParser('', new NullLogService());
44
45
testObject.parse(JSON.stringify({ '[x][y]': { 'a': 1 } }));
46
47
assert.deepStrictEqual(JSON.stringify(testObject.configurationModel.overrides), JSON.stringify([{ identifiers: ['x', 'y'], keys: ['a'], contents: { 'a': 1 } }]));
48
});
49
50
test('parse configuration model with multiple duplicate override identifiers', () => {
51
const testObject = new ConfigurationModelParser('', new NullLogService());
52
53
testObject.parse(JSON.stringify({ '[x][y][x][z]': { 'a': 1 } }));
54
55
assert.deepStrictEqual(JSON.stringify(testObject.configurationModel.overrides), JSON.stringify([{ identifiers: ['x', 'y', 'z'], keys: ['a'], contents: { 'a': 1 } }]));
56
});
57
58
test('parse configuration model with exclude option', () => {
59
const testObject = new ConfigurationModelParser('', new NullLogService());
60
61
testObject.parse(JSON.stringify({ 'a': 1, 'b': 2 }), { exclude: ['a'] });
62
63
assert.strictEqual(testObject.configurationModel.getValue('a'), undefined);
64
assert.strictEqual(testObject.configurationModel.getValue('b'), 2);
65
});
66
67
test('parse configuration model with exclude option even included', () => {
68
const testObject = new ConfigurationModelParser('', new NullLogService());
69
70
testObject.parse(JSON.stringify({ 'a': 1, 'b': 2 }), { exclude: ['a'], include: ['a'] });
71
72
assert.strictEqual(testObject.configurationModel.getValue('a'), undefined);
73
assert.strictEqual(testObject.configurationModel.getValue('b'), 2);
74
});
75
76
test('parse configuration model with scopes filter', () => {
77
const testObject = new ConfigurationModelParser('', new NullLogService());
78
79
testObject.parse(JSON.stringify({ 'ConfigurationModelParserTest.windowSetting': '1' }), { scopes: [ConfigurationScope.APPLICATION] });
80
81
assert.strictEqual(testObject.configurationModel.getValue('ConfigurationModelParserTest.windowSetting'), undefined);
82
});
83
84
test('parse configuration model with include option', () => {
85
const testObject = new ConfigurationModelParser('', new NullLogService());
86
87
testObject.parse(JSON.stringify({ 'ConfigurationModelParserTest.windowSetting': '1' }), { include: ['ConfigurationModelParserTest.windowSetting'], scopes: [ConfigurationScope.APPLICATION] });
88
89
assert.strictEqual(testObject.configurationModel.getValue('ConfigurationModelParserTest.windowSetting'), '1');
90
});
91
92
test('parse configuration model with invalid setting key', () => {
93
const testObject = new ConfigurationModelParser('', new NullLogService());
94
95
testObject.parse(JSON.stringify({ 'a': null, 'a.b.c': { c: 1 } }));
96
97
assert.strictEqual(testObject.configurationModel.getValue('a'), null);
98
assert.strictEqual(testObject.configurationModel.getValue('a.b'), undefined);
99
assert.strictEqual(testObject.configurationModel.getValue('a.b.c'), undefined);
100
});
101
102
});
103
104
suite('ConfigurationModelParser - Excluded Properties', () => {
105
106
ensureNoDisposablesAreLeakedInTestSuite();
107
108
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
109
110
let testConfigurationNodes: any[] = [];
111
112
setup(() => reset());
113
teardown(() => reset());
114
115
function reset() {
116
if (testConfigurationNodes.length > 0) {
117
configurationRegistry.deregisterConfigurations(testConfigurationNodes);
118
testConfigurationNodes = [];
119
}
120
}
121
122
function registerTestConfiguration() {
123
const node = {
124
'id': 'ExcludedPropertiesTest',
125
'type': 'object',
126
'properties': {
127
'regularProperty': {
128
'type': 'string' as const,
129
'default': 'regular',
130
'restricted': false
131
},
132
'restrictedProperty': {
133
'type': 'string' as const,
134
'default': 'restricted',
135
'restricted': true
136
},
137
'excludedProperty': {
138
'type': 'string' as const,
139
'default': 'excluded',
140
'restricted': true,
141
'included': false
142
},
143
'excludedNonRestrictedProperty': {
144
'type': 'string' as const,
145
'default': 'excludedNonRestricted',
146
'restricted': false,
147
'included': false
148
}
149
}
150
};
151
152
configurationRegistry.registerConfiguration(node);
153
testConfigurationNodes.push(node);
154
return node;
155
}
156
157
test('should handle excluded restricted properties correctly', () => {
158
registerTestConfiguration();
159
160
const testObject = new ConfigurationModelParser('test', new NullLogService());
161
const testData = {
162
'regularProperty': 'regularValue',
163
'restrictedProperty': 'restrictedValue',
164
'excludedProperty': 'excludedValue',
165
'excludedNonRestrictedProperty': 'excludedNonRestrictedValue'
166
};
167
168
testObject.parse(JSON.stringify(testData), { skipRestricted: true });
169
170
assert.strictEqual(testObject.configurationModel.getValue('regularProperty'), 'regularValue');
171
assert.strictEqual(testObject.configurationModel.getValue('restrictedProperty'), undefined);
172
assert.strictEqual(testObject.configurationModel.getValue('excludedProperty'), 'excludedValue');
173
assert.strictEqual(testObject.configurationModel.getValue('excludedNonRestrictedProperty'), 'excludedNonRestrictedValue');
174
assert.ok(testObject.restrictedConfigurations.includes('restrictedProperty'));
175
assert.ok(!testObject.restrictedConfigurations.includes('excludedProperty'));
176
});
177
178
test('should find excluded properties when checking for restricted settings', () => {
179
registerTestConfiguration();
180
181
const testObject = new ConfigurationModelParser('test', new NullLogService());
182
const testData = {
183
'excludedProperty': 'excludedValue'
184
};
185
186
testObject.parse(JSON.stringify(testData));
187
188
assert.strictEqual(testObject.configurationModel.getValue('excludedProperty'), 'excludedValue');
189
assert.ok(!testObject.restrictedConfigurations.includes('excludedProperty'));
190
});
191
192
test('should handle override properties with excluded configurations', () => {
193
registerTestConfiguration();
194
195
const testObject = new ConfigurationModelParser('test', new NullLogService());
196
const testData = {
197
'[typescript]': {
198
'regularProperty': 'overrideRegular',
199
'restrictedProperty': 'overrideRestricted',
200
'excludedProperty': 'overrideExcluded'
201
}
202
};
203
204
testObject.parse(JSON.stringify(testData), { skipRestricted: true });
205
206
const overrideConfig = testObject.configurationModel.override('typescript');
207
assert.strictEqual(overrideConfig.getValue('regularProperty'), 'overrideRegular');
208
assert.strictEqual(overrideConfig.getValue('restrictedProperty'), undefined);
209
assert.strictEqual(overrideConfig.getValue('excludedProperty'), 'overrideExcluded');
210
});
211
212
test('should handle scope filtering with excluded properties', () => {
213
const node = {
214
'id': 'ScopeExcludedTest',
215
'type': 'object',
216
'properties': {
217
'windowProperty': {
218
'type': 'string' as const,
219
'default': 'window',
220
'scope': ConfigurationScope.WINDOW
221
},
222
'applicationProperty': {
223
'type': 'string' as const,
224
'default': 'application',
225
'scope': ConfigurationScope.APPLICATION
226
},
227
'excludedApplicationProperty': {
228
'type': 'string' as const,
229
'default': 'excludedApplication',
230
'scope': ConfigurationScope.APPLICATION,
231
'included': false
232
}
233
}
234
};
235
236
configurationRegistry.registerConfiguration(node);
237
testConfigurationNodes.push(node);
238
239
const testObject = new ConfigurationModelParser('test', new NullLogService());
240
const testData = {
241
'windowProperty': 'windowValue',
242
'applicationProperty': 'applicationValue',
243
'excludedApplicationProperty': 'excludedApplicationValue'
244
};
245
246
testObject.parse(JSON.stringify(testData), { scopes: [ConfigurationScope.WINDOW] });
247
248
assert.strictEqual(testObject.configurationModel.getValue('windowProperty'), 'windowValue');
249
assert.strictEqual(testObject.configurationModel.getValue('applicationProperty'), undefined);
250
assert.strictEqual(testObject.configurationModel.getValue('excludedApplicationProperty'), undefined);
251
});
252
253
test('filter should handle include/exclude options with excluded properties', () => {
254
registerTestConfiguration();
255
256
const testObject = new ConfigurationModelParser('test', new NullLogService());
257
const testData = {
258
'regularProperty': 'regularValue',
259
'excludedProperty': 'excludedValue'
260
};
261
262
testObject.parse(JSON.stringify(testData), { include: ['excludedProperty'] });
263
264
assert.strictEqual(testObject.configurationModel.getValue('regularProperty'), 'regularValue');
265
assert.strictEqual(testObject.configurationModel.getValue('excludedProperty'), 'excludedValue');
266
});
267
268
test('should handle exclude options with excluded properties', () => {
269
registerTestConfiguration();
270
271
const testObject = new ConfigurationModelParser('test', new NullLogService());
272
const testData = {
273
'regularProperty': 'regularValue',
274
'excludedProperty': 'excludedValue'
275
};
276
277
testObject.parse(JSON.stringify(testData), { exclude: ['regularProperty'] });
278
279
assert.strictEqual(testObject.configurationModel.getValue('regularProperty'), undefined);
280
assert.strictEqual(testObject.configurationModel.getValue('excludedProperty'), 'excludedValue');
281
});
282
283
test('should report hasExcludedProperties correctly when excluded properties are filtered', () => {
284
registerTestConfiguration();
285
286
const testObject = new ConfigurationModelParser('test', new NullLogService());
287
const testData = {
288
'regularProperty': 'regularValue',
289
'restrictedProperty': 'restrictedValue',
290
'excludedProperty': 'excludedValue'
291
};
292
293
testObject.parse(JSON.stringify(testData), { skipRestricted: true });
294
295
const model = testObject.configurationModel;
296
297
assert.notStrictEqual(model.raw, undefined, 'Raw should be set when properties are excluded');
298
});
299
300
test('skipUnregistered should exclude unregistered properties', () => {
301
registerTestConfiguration();
302
303
const testObject = new ConfigurationModelParser('test', new NullLogService());
304
305
testObject.parse(JSON.stringify({
306
'unregisteredProperty': 'value3'
307
}), { skipUnregistered: true });
308
309
assert.strictEqual(testObject.configurationModel.getValue('unregisteredProperty'), undefined);
310
});
311
312
test('shouldInclude method works correctly with excluded properties for skipUnregistered', () => {
313
registerTestConfiguration();
314
315
const testObject = new ConfigurationModelParser('test', new NullLogService());
316
317
testObject.parse(JSON.stringify({
318
'regularProperty': 'value1',
319
'excludedProperty': 'value2',
320
'unregisteredProperty': 'value3'
321
}), { skipUnregistered: true });
322
323
assert.strictEqual(testObject.configurationModel.getValue('regularProperty'), 'value1');
324
assert.strictEqual(testObject.configurationModel.getValue('excludedProperty'), undefined);
325
assert.strictEqual(testObject.configurationModel.getValue('unregisteredProperty'), undefined);
326
});
327
328
test('excluded properties are found during property schema lookup', () => {
329
registerTestConfiguration();
330
331
const registry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
332
333
const excludedProperties = registry.getExcludedConfigurationProperties();
334
assert.ok(excludedProperties['excludedProperty'], 'Excluded property should be in excluded properties map');
335
assert.ok(excludedProperties['excludedNonRestrictedProperty'], 'Excluded non-restricted property should be in excluded properties map');
336
337
const regularProperties = registry.getConfigurationProperties();
338
assert.strictEqual(regularProperties['excludedProperty'], undefined, 'Excluded property should not be in regular properties map');
339
assert.strictEqual(regularProperties['excludedNonRestrictedProperty'], undefined, 'Excluded non-restricted property should not be in regular properties map');
340
341
assert.ok(regularProperties['regularProperty'], 'Regular property should be in regular properties map');
342
assert.ok(regularProperties['restrictedProperty'], 'Restricted property should be in regular properties map');
343
});
344
345
test('should correctly use shouldInclude with excluded properties for scope and unregistered filtering', () => {
346
registerTestConfiguration();
347
348
const testObject = new ConfigurationModelParser('test', new NullLogService());
349
const testData = {
350
'regularProperty': 'regularValue',
351
'restrictedProperty': 'restrictedValue',
352
'excludedProperty': 'excludedValue',
353
'excludedNonRestrictedProperty': 'excludedNonRestrictedValue',
354
'unknownProperty': 'unknownValue'
355
};
356
357
testObject.parse(JSON.stringify(testData), { skipRestricted: true });
358
359
assert.strictEqual(testObject.configurationModel.getValue('regularProperty'), 'regularValue');
360
assert.strictEqual(testObject.configurationModel.getValue('restrictedProperty'), undefined);
361
assert.ok(testObject.restrictedConfigurations.includes('restrictedProperty'));
362
assert.strictEqual(testObject.configurationModel.getValue('excludedProperty'), 'excludedValue');
363
assert.ok(!testObject.restrictedConfigurations.includes('excludedProperty'));
364
assert.strictEqual(testObject.configurationModel.getValue('excludedNonRestrictedProperty'), 'excludedNonRestrictedValue');
365
assert.strictEqual(testObject.configurationModel.getValue('unknownProperty'), 'unknownValue');
366
});
367
});
368
369
suite('ConfigurationModel', () => {
370
371
ensureNoDisposablesAreLeakedInTestSuite();
372
373
test('setValue for a key that has no sections and not defined', () => {
374
const testObject = new ConfigurationModel({ 'a': { 'b': 1 } }, ['a.b'], [], undefined, new NullLogService());
375
376
testObject.setValue('f', 1);
377
378
assert.deepStrictEqual(testObject.contents, { 'a': { 'b': 1 }, 'f': 1 });
379
assert.deepStrictEqual(testObject.keys, ['a.b', 'f']);
380
});
381
382
test('setValue for a key that has no sections and defined', () => {
383
const testObject = new ConfigurationModel({ 'a': { 'b': 1 }, 'f': 1 }, ['a.b', 'f'], [], undefined, new NullLogService());
384
385
testObject.setValue('f', 3);
386
387
assert.deepStrictEqual(testObject.contents, { 'a': { 'b': 1 }, 'f': 3 });
388
assert.deepStrictEqual(testObject.keys, ['a.b', 'f']);
389
});
390
391
test('setValue for a key that has sections and not defined', () => {
392
const testObject = new ConfigurationModel({ 'a': { 'b': 1 }, 'f': 1 }, ['a.b', 'f'], [], undefined, new NullLogService());
393
394
testObject.setValue('b.c', 1);
395
396
const expected: any = {};
397
expected['a'] = { 'b': 1 };
398
expected['f'] = 1;
399
expected['b'] = Object.create(null);
400
expected['b']['c'] = 1;
401
assert.deepStrictEqual(testObject.contents, expected);
402
assert.deepStrictEqual(testObject.keys, ['a.b', 'f', 'b.c']);
403
});
404
405
test('setValue for a key that has sections and defined', () => {
406
const testObject = new ConfigurationModel({ 'a': { 'b': 1 }, 'b': { 'c': 1 }, 'f': 1 }, ['a.b', 'b.c', 'f'], [], undefined, new NullLogService());
407
408
testObject.setValue('b.c', 3);
409
410
assert.deepStrictEqual(testObject.contents, { 'a': { 'b': 1 }, 'b': { 'c': 3 }, 'f': 1 });
411
assert.deepStrictEqual(testObject.keys, ['a.b', 'b.c', 'f']);
412
});
413
414
test('setValue for a key that has sections and sub section not defined', () => {
415
const testObject = new ConfigurationModel({ 'a': { 'b': 1 }, 'f': 1 }, ['a.b', 'f'], [], undefined, new NullLogService());
416
417
testObject.setValue('a.c', 1);
418
419
assert.deepStrictEqual(testObject.contents, { 'a': { 'b': 1, 'c': 1 }, 'f': 1 });
420
assert.deepStrictEqual(testObject.keys, ['a.b', 'f', 'a.c']);
421
});
422
423
test('setValue for a key that has sections and sub section defined', () => {
424
const testObject = new ConfigurationModel({ 'a': { 'b': 1, 'c': 1 }, 'f': 1 }, ['a.b', 'a.c', 'f'], [], undefined, new NullLogService());
425
426
testObject.setValue('a.c', 3);
427
428
assert.deepStrictEqual(testObject.contents, { 'a': { 'b': 1, 'c': 3 }, 'f': 1 });
429
assert.deepStrictEqual(testObject.keys, ['a.b', 'a.c', 'f']);
430
});
431
432
test('setValue for a key that has sections and last section is added', () => {
433
const testObject = new ConfigurationModel({ 'a': { 'b': {} }, 'f': 1 }, ['a.b', 'f'], [], undefined, new NullLogService());
434
435
testObject.setValue('a.b.c', 1);
436
437
assert.deepStrictEqual(testObject.contents, { 'a': { 'b': { 'c': 1 } }, 'f': 1 });
438
assert.deepStrictEqual(testObject.keys, ['a.b', 'f', 'a.b.c']);
439
});
440
441
test('removeValue: remove a non existing key', () => {
442
const testObject = new ConfigurationModel({ 'a': { 'b': 2 } }, ['a.b'], [], undefined, new NullLogService());
443
444
testObject.removeValue('a.b.c');
445
446
assert.deepStrictEqual(testObject.contents, { 'a': { 'b': 2 } });
447
assert.deepStrictEqual(testObject.keys, ['a.b']);
448
});
449
450
test('removeValue: remove a single segmented key', () => {
451
const testObject = new ConfigurationModel({ 'a': 1 }, ['a'], [], undefined, new NullLogService());
452
453
testObject.removeValue('a');
454
455
assert.deepStrictEqual(testObject.contents, {});
456
assert.deepStrictEqual(testObject.keys, []);
457
});
458
459
test('removeValue: remove a multi segmented key', () => {
460
const testObject = new ConfigurationModel({ 'a': { 'b': 1 } }, ['a.b'], [], undefined, new NullLogService());
461
462
testObject.removeValue('a.b');
463
464
assert.deepStrictEqual(testObject.contents, {});
465
assert.deepStrictEqual(testObject.keys, []);
466
});
467
468
test('get overriding configuration model for an existing identifier', () => {
469
const testObject = new ConfigurationModel(
470
{ 'a': { 'b': 1 }, 'f': 1 }, [],
471
[{ identifiers: ['c'], contents: { 'a': { 'd': 1 } }, keys: ['a'] }], [], new NullLogService());
472
473
assert.deepStrictEqual(testObject.override('c').contents, { 'a': { 'b': 1, 'd': 1 }, 'f': 1 });
474
});
475
476
test('get overriding configuration model for an identifier that does not exist', () => {
477
const testObject = new ConfigurationModel(
478
{ 'a': { 'b': 1 }, 'f': 1 }, [],
479
[{ identifiers: ['c'], contents: { 'a': { 'd': 1 } }, keys: ['a'] }], [], new NullLogService());
480
481
assert.deepStrictEqual(testObject.override('xyz').contents, { 'a': { 'b': 1 }, 'f': 1 });
482
});
483
484
test('get overriding configuration when one of the keys does not exist in base', () => {
485
const testObject = new ConfigurationModel(
486
{ 'a': { 'b': 1 }, 'f': 1 }, [],
487
[{ identifiers: ['c'], contents: { 'a': { 'd': 1 }, 'g': 1 }, keys: ['a', 'g'] }], [], new NullLogService());
488
489
assert.deepStrictEqual(testObject.override('c').contents, { 'a': { 'b': 1, 'd': 1 }, 'f': 1, 'g': 1 });
490
});
491
492
test('get overriding configuration when one of the key in base is not of object type', () => {
493
const testObject = new ConfigurationModel(
494
{ 'a': { 'b': 1 }, 'f': 1 }, [],
495
[{ identifiers: ['c'], contents: { 'a': { 'd': 1 }, 'f': { 'g': 1 } }, keys: ['a', 'f'] }], [], new NullLogService());
496
497
assert.deepStrictEqual(testObject.override('c').contents, { 'a': { 'b': 1, 'd': 1 }, 'f': { 'g': 1 } });
498
});
499
500
test('get overriding configuration when one of the key in overriding contents is not of object type', () => {
501
const testObject = new ConfigurationModel(
502
{ 'a': { 'b': 1 }, 'f': { 'g': 1 } }, [],
503
[{ identifiers: ['c'], contents: { 'a': { 'd': 1 }, 'f': 1 }, keys: ['a', 'f'] }], [], new NullLogService());
504
505
assert.deepStrictEqual(testObject.override('c').contents, { 'a': { 'b': 1, 'd': 1 }, 'f': 1 });
506
});
507
508
test('get overriding configuration if the value of overriding identifier is not object', () => {
509
const testObject = new ConfigurationModel(
510
{ 'a': { 'b': 1 }, 'f': { 'g': 1 } }, [],
511
[{ identifiers: ['c'], contents: 'abc', keys: [] }], [], new NullLogService());
512
513
assert.deepStrictEqual(testObject.override('c').contents, { 'a': { 'b': 1 }, 'f': { 'g': 1 } });
514
});
515
516
test('get overriding configuration if the value of overriding identifier is an empty object', () => {
517
const testObject = new ConfigurationModel(
518
{ 'a': { 'b': 1 }, 'f': { 'g': 1 } }, [],
519
[{ identifiers: ['c'], contents: {}, keys: [] }], [], new NullLogService());
520
521
assert.deepStrictEqual(testObject.override('c').contents, { 'a': { 'b': 1 }, 'f': { 'g': 1 } });
522
});
523
524
test('simple merge', () => {
525
const base = new ConfigurationModel({ 'a': 1, 'b': 2 }, ['a', 'b'], [], undefined, new NullLogService());
526
const add = new ConfigurationModel({ 'a': 3, 'c': 4 }, ['a', 'c'], [], undefined, new NullLogService());
527
const result = base.merge(add);
528
529
assert.deepStrictEqual(result.contents, { 'a': 3, 'b': 2, 'c': 4 });
530
assert.deepStrictEqual(result.keys, ['a', 'b', 'c']);
531
});
532
533
test('recursive merge', () => {
534
const base = new ConfigurationModel({ 'a': { 'b': 1 } }, ['a.b'], [], undefined, new NullLogService());
535
const add = new ConfigurationModel({ 'a': { 'b': 2 } }, ['a.b'], [], undefined, new NullLogService());
536
const result = base.merge(add);
537
538
assert.deepStrictEqual(result.contents, { 'a': { 'b': 2 } });
539
assert.deepStrictEqual(result.getValue('a'), { 'b': 2 });
540
assert.deepStrictEqual(result.keys, ['a.b']);
541
});
542
543
test('simple merge overrides', () => {
544
const base = new ConfigurationModel({ 'a': { 'b': 1 } }, ['a.b'], [{ identifiers: ['c'], contents: { 'a': 2 }, keys: ['a'] }], undefined, new NullLogService());
545
const add = new ConfigurationModel({ 'a': { 'b': 2 } }, ['a.b'], [{ identifiers: ['c'], contents: { 'b': 2 }, keys: ['b'] }], undefined, new NullLogService());
546
const result = base.merge(add);
547
548
assert.deepStrictEqual(result.contents, { 'a': { 'b': 2 } });
549
assert.deepStrictEqual(result.overrides, [{ identifiers: ['c'], contents: { 'a': 2, 'b': 2 }, keys: ['a', 'b'] }]);
550
assert.deepStrictEqual(result.override('c').contents, { 'a': 2, 'b': 2 });
551
assert.deepStrictEqual(result.keys, ['a.b']);
552
});
553
554
test('recursive merge overrides', () => {
555
const base = new ConfigurationModel({ 'a': { 'b': 1 }, 'f': 1 }, ['a.b', 'f'], [{ identifiers: ['c'], contents: { 'a': { 'd': 1 } }, keys: ['a'] }], undefined, new NullLogService());
556
const add = new ConfigurationModel({ 'a': { 'b': 2 } }, ['a.b'], [{ identifiers: ['c'], contents: { 'a': { 'e': 2 } }, keys: ['a'] }], undefined, new NullLogService());
557
const result = base.merge(add);
558
559
assert.deepStrictEqual(result.contents, { 'a': { 'b': 2 }, 'f': 1 });
560
assert.deepStrictEqual(result.overrides, [{ identifiers: ['c'], contents: { 'a': { 'd': 1, 'e': 2 } }, keys: ['a'] }]);
561
assert.deepStrictEqual(result.override('c').contents, { 'a': { 'b': 2, 'd': 1, 'e': 2 }, 'f': 1 });
562
assert.deepStrictEqual(result.keys, ['a.b', 'f']);
563
});
564
565
test('Test contents while getting an existing property', () => {
566
let testObject = new ConfigurationModel({ 'a': 1 }, [], [], undefined, new NullLogService());
567
assert.deepStrictEqual(testObject.getValue('a'), 1);
568
569
testObject = new ConfigurationModel({ 'a': { 'b': 1 } }, [], [], undefined, new NullLogService());
570
assert.deepStrictEqual(testObject.getValue('a'), { 'b': 1 });
571
});
572
573
test('Test contents are undefined for non existing properties', () => {
574
const testObject = new ConfigurationModel({ awesome: true }, [], [], undefined, new NullLogService());
575
576
assert.deepStrictEqual(testObject.getValue('unknownproperty'), undefined);
577
});
578
579
test('Test override gives all content merged with overrides', () => {
580
const testObject = new ConfigurationModel({ 'a': 1, 'c': 1 }, [], [{ identifiers: ['b'], contents: { 'a': 2 }, keys: ['a'] }], undefined, new NullLogService());
581
582
assert.deepStrictEqual(testObject.override('b').contents, { 'a': 2, 'c': 1 });
583
});
584
585
test('Test override when an override has multiple identifiers', () => {
586
const testObject = new ConfigurationModel({ 'a': 1, 'c': 1 }, ['a', 'c'], [{ identifiers: ['x', 'y'], contents: { 'a': 2 }, keys: ['a'] }], undefined, new NullLogService());
587
588
let actual = testObject.override('x');
589
assert.deepStrictEqual(actual.contents, { 'a': 2, 'c': 1 });
590
assert.deepStrictEqual(actual.keys, ['a', 'c']);
591
assert.deepStrictEqual(testObject.getKeysForOverrideIdentifier('x'), ['a']);
592
593
actual = testObject.override('y');
594
assert.deepStrictEqual(actual.contents, { 'a': 2, 'c': 1 });
595
assert.deepStrictEqual(actual.keys, ['a', 'c']);
596
assert.deepStrictEqual(testObject.getKeysForOverrideIdentifier('y'), ['a']);
597
});
598
599
test('Test override when an identifier is defined in multiple overrides', () => {
600
const testObject = new ConfigurationModel({ 'a': 1, 'c': 1 }, ['a', 'c'], [{ identifiers: ['x'], contents: { 'a': 3, 'b': 1 }, keys: ['a', 'b'] }, { identifiers: ['x', 'y'], contents: { 'a': 2 }, keys: ['a'] }], undefined, new NullLogService());
601
602
const actual = testObject.override('x');
603
assert.deepStrictEqual(actual.contents, { 'a': 3, 'c': 1, 'b': 1 });
604
assert.deepStrictEqual(actual.keys, ['a', 'c']);
605
606
assert.deepStrictEqual(testObject.getKeysForOverrideIdentifier('x'), ['a', 'b']);
607
});
608
609
test('Test merge when configuration models have multiple identifiers', () => {
610
const testObject = new ConfigurationModel({ 'a': 1, 'c': 1 }, ['a', 'c'], [{ identifiers: ['y'], contents: { 'c': 1 }, keys: ['c'] }, { identifiers: ['x', 'y'], contents: { 'a': 2 }, keys: ['a'] }], undefined, new NullLogService());
611
const target = new ConfigurationModel({ 'a': 2, 'b': 1 }, ['a', 'b'], [{ identifiers: ['x'], contents: { 'a': 3, 'b': 2 }, keys: ['a', 'b'] }, { identifiers: ['x', 'y'], contents: { 'b': 3 }, keys: ['b'] }], undefined, new NullLogService());
612
613
const actual = testObject.merge(target);
614
615
assert.deepStrictEqual(actual.contents, { 'a': 2, 'c': 1, 'b': 1 });
616
assert.deepStrictEqual(actual.keys, ['a', 'c', 'b']);
617
assert.deepStrictEqual(actual.overrides, [
618
{ identifiers: ['y'], contents: { 'c': 1 }, keys: ['c'] },
619
{ identifiers: ['x', 'y'], contents: { 'a': 2, 'b': 3 }, keys: ['a', 'b'] },
620
{ identifiers: ['x'], contents: { 'a': 3, 'b': 2 }, keys: ['a', 'b'] },
621
]);
622
});
623
624
test('inspect when raw is same', () => {
625
const testObject = new ConfigurationModel({ 'a': 1, 'c': 1 }, ['a', 'c'], [{ identifiers: ['x', 'y'], contents: { 'a': 2, 'b': 1 }, keys: ['a'] }], undefined, new NullLogService());
626
627
assert.deepStrictEqual(testObject.inspect('a'), { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
628
assert.deepStrictEqual(testObject.inspect('a', 'x'), { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
629
assert.deepStrictEqual(testObject.inspect('b', 'x'), { value: undefined, override: 1, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 1 }] });
630
assert.deepStrictEqual(testObject.inspect('d'), { value: undefined, override: undefined, merged: undefined, overrides: undefined });
631
});
632
633
test('inspect when raw is not same', () => {
634
const testObject = new ConfigurationModel({ 'a': 1, 'c': 1 }, ['a', 'c'], [{ identifiers: ['x', 'y'], contents: { 'a': 2, }, keys: ['a'] }], {
635
'a': 1,
636
'b': 2,
637
'c': 1,
638
'd': 3,
639
'[x][y]': {
640
'a': 2,
641
'b': 1
642
}
643
}, new NullLogService());
644
645
assert.deepStrictEqual(testObject.inspect('a'), { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
646
assert.deepStrictEqual(testObject.inspect('a', 'x'), { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
647
assert.deepStrictEqual(testObject.inspect('b', 'x'), { value: 2, override: 1, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 1 }] });
648
assert.deepStrictEqual(testObject.inspect('d'), { value: 3, override: undefined, merged: 3, overrides: undefined });
649
assert.deepStrictEqual(testObject.inspect('e'), { value: undefined, override: undefined, merged: undefined, overrides: undefined });
650
});
651
652
test('inspect in merged configuration when raw is same', () => {
653
const target1 = new ConfigurationModel({ 'a': 1 }, ['a'], [{ identifiers: ['x', 'y'], contents: { 'a': 2, }, keys: ['a'] }], undefined, new NullLogService());
654
const target2 = new ConfigurationModel({ 'b': 3 }, ['b'], [], undefined, new NullLogService());
655
const testObject = target1.merge(target2);
656
657
assert.deepStrictEqual(testObject.inspect('a'), { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
658
assert.deepStrictEqual(testObject.inspect('a', 'x'), { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
659
assert.deepStrictEqual(testObject.inspect('b'), { value: 3, override: undefined, merged: 3, overrides: undefined });
660
assert.deepStrictEqual(testObject.inspect('b', 'y'), { value: 3, override: undefined, merged: 3, overrides: undefined });
661
assert.deepStrictEqual(testObject.inspect('c'), { value: undefined, override: undefined, merged: undefined, overrides: undefined });
662
});
663
664
test('inspect in merged configuration when raw is not same for one model', () => {
665
const target1 = new ConfigurationModel({ 'a': 1 }, ['a'], [{ identifiers: ['x', 'y'], contents: { 'a': 2, }, keys: ['a'] }], {
666
'a': 1,
667
'b': 2,
668
'c': 3,
669
'[x][y]': {
670
'a': 2,
671
'b': 4,
672
}
673
}, new NullLogService());
674
const target2 = new ConfigurationModel({ 'b': 3 }, ['b'], [], undefined, new NullLogService());
675
const testObject = target1.merge(target2);
676
677
assert.deepStrictEqual(testObject.inspect('a'), { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
678
assert.deepStrictEqual(testObject.inspect('a', 'x'), { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
679
assert.deepStrictEqual(testObject.inspect('b'), { value: 3, override: undefined, merged: 3, overrides: [{ identifiers: ['x', 'y'], value: 4 }] });
680
assert.deepStrictEqual(testObject.inspect('b', 'y'), { value: 3, override: 4, merged: 4, overrides: [{ identifiers: ['x', 'y'], value: 4 }] });
681
assert.deepStrictEqual(testObject.inspect('c'), { value: 3, override: undefined, merged: 3, overrides: undefined });
682
});
683
684
test('inspect: return all overrides', () => {
685
const testObject = new ConfigurationModel({ 'a': 1, 'c': 1 }, ['a', 'c'], [
686
{ identifiers: ['x', 'y'], contents: { 'a': 2, 'b': 1 }, keys: ['a', 'b'] },
687
{ identifiers: ['x'], contents: { 'a': 3 }, keys: ['a'] },
688
{ identifiers: ['y'], contents: { 'b': 3 }, keys: ['b'] }
689
], undefined, new NullLogService());
690
691
assert.deepStrictEqual(testObject.inspect('a').overrides, [
692
{ identifiers: ['x', 'y'], value: 2 },
693
{ identifiers: ['x'], value: 3 }
694
]);
695
});
696
697
test('inspect when no overrides', () => {
698
const testObject = new ConfigurationModel({ 'a': 1, 'c': 1 }, ['a', 'c'], [], undefined, new NullLogService());
699
700
assert.strictEqual(testObject.inspect('a').overrides, undefined);
701
});
702
703
});
704
705
suite('CustomConfigurationModel', () => {
706
707
ensureNoDisposablesAreLeakedInTestSuite();
708
709
test('simple merge using models', () => {
710
const base = new ConfigurationModelParser('base', new NullLogService());
711
base.parse(JSON.stringify({ 'a': 1, 'b': 2 }));
712
713
const add = new ConfigurationModelParser('add', new NullLogService());
714
add.parse(JSON.stringify({ 'a': 3, 'c': 4 }));
715
716
const result = base.configurationModel.merge(add.configurationModel);
717
assert.deepStrictEqual(result.contents, { 'a': 3, 'b': 2, 'c': 4 });
718
});
719
720
test('simple merge with an undefined contents', () => {
721
let base = new ConfigurationModelParser('base', new NullLogService());
722
base.parse(JSON.stringify({ 'a': 1, 'b': 2 }));
723
let add = new ConfigurationModelParser('add', new NullLogService());
724
let result = base.configurationModel.merge(add.configurationModel);
725
assert.deepStrictEqual(result.contents, { 'a': 1, 'b': 2 });
726
727
base = new ConfigurationModelParser('base', new NullLogService());
728
add = new ConfigurationModelParser('add', new NullLogService());
729
add.parse(JSON.stringify({ 'a': 1, 'b': 2 }));
730
result = base.configurationModel.merge(add.configurationModel);
731
assert.deepStrictEqual(result.contents, { 'a': 1, 'b': 2 });
732
733
base = new ConfigurationModelParser('base', new NullLogService());
734
add = new ConfigurationModelParser('add', new NullLogService());
735
result = base.configurationModel.merge(add.configurationModel);
736
assert.deepStrictEqual(result.contents, {});
737
});
738
739
test('Recursive merge using config models', () => {
740
const base = new ConfigurationModelParser('base', new NullLogService());
741
base.parse(JSON.stringify({ 'a': { 'b': 1 } }));
742
const add = new ConfigurationModelParser('add', new NullLogService());
743
add.parse(JSON.stringify({ 'a': { 'b': 2 } }));
744
const result = base.configurationModel.merge(add.configurationModel);
745
assert.deepStrictEqual(result.contents, { 'a': { 'b': 2 } });
746
});
747
748
test('Test contents while getting an existing property', () => {
749
const testObject = new ConfigurationModelParser('test', new NullLogService());
750
testObject.parse(JSON.stringify({ 'a': 1 }));
751
assert.deepStrictEqual(testObject.configurationModel.getValue('a'), 1);
752
753
testObject.parse(JSON.stringify({ 'a': { 'b': 1 } }));
754
assert.deepStrictEqual(testObject.configurationModel.getValue('a'), { 'b': 1 });
755
});
756
757
test('Test contents are undefined for non existing properties', () => {
758
const testObject = new ConfigurationModelParser('test', new NullLogService());
759
testObject.parse(JSON.stringify({
760
awesome: true
761
}));
762
763
assert.deepStrictEqual(testObject.configurationModel.getValue('unknownproperty'), undefined);
764
});
765
766
test('Test contents are undefined for undefined config', () => {
767
const testObject = new ConfigurationModelParser('test', new NullLogService());
768
769
assert.deepStrictEqual(testObject.configurationModel.getValue('unknownproperty'), undefined);
770
});
771
772
test('Test configWithOverrides gives all content merged with overrides', () => {
773
const testObject = new ConfigurationModelParser('test', new NullLogService());
774
testObject.parse(JSON.stringify({ 'a': 1, 'c': 1, '[b]': { 'a': 2 } }));
775
776
assert.deepStrictEqual(testObject.configurationModel.override('b').contents, { 'a': 2, 'c': 1, '[b]': { 'a': 2 } });
777
});
778
779
test('Test configWithOverrides gives empty contents', () => {
780
const testObject = new ConfigurationModelParser('test', new NullLogService());
781
782
assert.deepStrictEqual(testObject.configurationModel.override('b').contents, {});
783
});
784
785
test('Test update with empty data', () => {
786
const testObject = new ConfigurationModelParser('test', new NullLogService());
787
testObject.parse('');
788
789
assert.deepStrictEqual(testObject.configurationModel.contents, Object.create(null));
790
assert.deepStrictEqual(testObject.configurationModel.keys, []);
791
792
testObject.parse(null);
793
794
assert.deepStrictEqual(testObject.configurationModel.contents, Object.create(null));
795
assert.deepStrictEqual(testObject.configurationModel.keys, []);
796
797
testObject.parse(undefined);
798
799
assert.deepStrictEqual(testObject.configurationModel.contents, Object.create(null));
800
assert.deepStrictEqual(testObject.configurationModel.keys, []);
801
});
802
803
test('Test empty property is not ignored', () => {
804
const testObject = new ConfigurationModelParser('test', new NullLogService());
805
testObject.parse(JSON.stringify({ '': 1 }));
806
807
// deepStrictEqual seems to ignore empty properties, fall back
808
// to comparing the output of JSON.stringify
809
assert.strictEqual(JSON.stringify(testObject.configurationModel.contents), JSON.stringify({ '': 1 }));
810
assert.deepStrictEqual(testObject.configurationModel.keys, ['']);
811
});
812
813
});
814
815
export class TestConfiguration extends Configuration {
816
817
constructor(
818
defaultConfiguration: ConfigurationModel,
819
policyConfiguration: ConfigurationModel,
820
applicationConfiguration: ConfigurationModel,
821
localUserConfiguration: ConfigurationModel,
822
remoteUserConfiguration?: ConfigurationModel,
823
) {
824
super(
825
defaultConfiguration,
826
policyConfiguration,
827
applicationConfiguration,
828
localUserConfiguration,
829
remoteUserConfiguration ?? ConfigurationModel.createEmptyModel(new NullLogService()),
830
ConfigurationModel.createEmptyModel(new NullLogService()),
831
new ResourceMap<ConfigurationModel>(),
832
ConfigurationModel.createEmptyModel(new NullLogService()),
833
new ResourceMap<ConfigurationModel>(),
834
new NullLogService()
835
);
836
}
837
838
}
839
840
suite('Configuration', () => {
841
842
ensureNoDisposablesAreLeakedInTestSuite();
843
844
test('Test inspect for overrideIdentifiers', () => {
845
const defaultConfigurationModel = parseConfigurationModel({ '[l1]': { 'a': 1 }, '[l2]': { 'b': 1 } });
846
const userConfigurationModel = parseConfigurationModel({ '[l3]': { 'a': 2 } });
847
const workspaceConfigurationModel = parseConfigurationModel({ '[l1]': { 'a': 3 }, '[l4]': { 'a': 3 } });
848
const testObject: Configuration = new TestConfiguration(defaultConfigurationModel, ConfigurationModel.createEmptyModel(new NullLogService()), userConfigurationModel, workspaceConfigurationModel);
849
850
const { overrideIdentifiers } = testObject.inspect('a', {}, undefined);
851
852
assert.deepStrictEqual(overrideIdentifiers, ['l1', 'l3', 'l4']);
853
});
854
855
test('Test update value', () => {
856
const parser = new ConfigurationModelParser('test', new NullLogService());
857
parser.parse(JSON.stringify({ 'a': 1 }));
858
const testObject: Configuration = new TestConfiguration(parser.configurationModel, ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
859
860
testObject.updateValue('a', 2);
861
862
assert.strictEqual(testObject.getValue('a', {}, undefined), 2);
863
});
864
865
test('Test update value after inspect', () => {
866
const parser = new ConfigurationModelParser('test', new NullLogService());
867
parser.parse(JSON.stringify({ 'a': 1 }));
868
const testObject: Configuration = new TestConfiguration(parser.configurationModel, ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
869
870
testObject.inspect('a', {}, undefined);
871
testObject.updateValue('a', 2);
872
873
assert.strictEqual(testObject.getValue('a', {}, undefined), 2);
874
});
875
876
test('Test compare and update default configuration', () => {
877
const testObject = new TestConfiguration(ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
878
testObject.updateDefaultConfiguration(toConfigurationModel({
879
'editor.lineNumbers': 'on',
880
}));
881
882
const actual = testObject.compareAndUpdateDefaultConfiguration(toConfigurationModel({
883
'editor.lineNumbers': 'off',
884
'[markdown]': {
885
'editor.wordWrap': 'off'
886
}
887
}), ['editor.lineNumbers', '[markdown]']);
888
889
assert.deepStrictEqual(actual, { keys: ['editor.lineNumbers', '[markdown]'], overrides: [['markdown', ['editor.wordWrap']]] });
890
891
});
892
893
test('Test compare and update application configuration', () => {
894
const testObject = new TestConfiguration(ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
895
testObject.updateApplicationConfiguration(toConfigurationModel({
896
'update.mode': 'on',
897
}));
898
899
const actual = testObject.compareAndUpdateApplicationConfiguration(toConfigurationModel({
900
'update.mode': 'none',
901
'[typescript]': {
902
'editor.wordWrap': 'off'
903
}
904
}));
905
906
assert.deepStrictEqual(actual, { keys: ['[typescript]', 'update.mode',], overrides: [['typescript', ['editor.wordWrap']]] });
907
908
});
909
910
test('Test compare and update user configuration', () => {
911
const testObject = new TestConfiguration(ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
912
testObject.updateLocalUserConfiguration(toConfigurationModel({
913
'editor.lineNumbers': 'off',
914
'editor.fontSize': 12,
915
'[typescript]': {
916
'editor.wordWrap': 'off'
917
}
918
}));
919
920
const actual = testObject.compareAndUpdateLocalUserConfiguration(toConfigurationModel({
921
'editor.lineNumbers': 'on',
922
'window.zoomLevel': 1,
923
'[typescript]': {
924
'editor.wordWrap': 'on',
925
'editor.insertSpaces': false
926
}
927
}));
928
929
assert.deepStrictEqual(actual, { keys: ['window.zoomLevel', 'editor.lineNumbers', '[typescript]', 'editor.fontSize'], overrides: [['typescript', ['editor.insertSpaces', 'editor.wordWrap']]] });
930
931
});
932
933
test('Test compare and update workspace configuration', () => {
934
const testObject = new TestConfiguration(ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
935
testObject.updateWorkspaceConfiguration(toConfigurationModel({
936
'editor.lineNumbers': 'off',
937
'editor.fontSize': 12,
938
'[typescript]': {
939
'editor.wordWrap': 'off'
940
}
941
}));
942
943
const actual = testObject.compareAndUpdateWorkspaceConfiguration(toConfigurationModel({
944
'editor.lineNumbers': 'on',
945
'window.zoomLevel': 1,
946
'[typescript]': {
947
'editor.wordWrap': 'on',
948
'editor.insertSpaces': false
949
}
950
}));
951
952
assert.deepStrictEqual(actual, { keys: ['window.zoomLevel', 'editor.lineNumbers', '[typescript]', 'editor.fontSize'], overrides: [['typescript', ['editor.insertSpaces', 'editor.wordWrap']]] });
953
954
});
955
956
test('Test compare and update workspace folder configuration', () => {
957
const testObject = new TestConfiguration(ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
958
testObject.updateFolderConfiguration(URI.file('file1'), toConfigurationModel({
959
'editor.lineNumbers': 'off',
960
'editor.fontSize': 12,
961
'[typescript]': {
962
'editor.wordWrap': 'off'
963
}
964
}));
965
966
const actual = testObject.compareAndUpdateFolderConfiguration(URI.file('file1'), toConfigurationModel({
967
'editor.lineNumbers': 'on',
968
'window.zoomLevel': 1,
969
'[typescript]': {
970
'editor.wordWrap': 'on',
971
'editor.insertSpaces': false
972
}
973
}));
974
975
assert.deepStrictEqual(actual, { keys: ['window.zoomLevel', 'editor.lineNumbers', '[typescript]', 'editor.fontSize'], overrides: [['typescript', ['editor.insertSpaces', 'editor.wordWrap']]] });
976
977
});
978
979
test('Test compare and delete workspace folder configuration', () => {
980
const testObject = new TestConfiguration(ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
981
testObject.updateFolderConfiguration(URI.file('file1'), toConfigurationModel({
982
'editor.lineNumbers': 'off',
983
'editor.fontSize': 12,
984
'[typescript]': {
985
'editor.wordWrap': 'off'
986
}
987
}));
988
989
const actual = testObject.compareAndDeleteFolderConfiguration(URI.file('file1'));
990
991
assert.deepStrictEqual(actual, { keys: ['editor.lineNumbers', 'editor.fontSize', '[typescript]'], overrides: [['typescript', ['editor.wordWrap']]] });
992
993
});
994
995
function parseConfigurationModel(content: any): ConfigurationModel {
996
const parser = new ConfigurationModelParser('test', new NullLogService());
997
parser.parse(JSON.stringify(content));
998
return parser.configurationModel;
999
}
1000
1001
});
1002
1003
suite('ConfigurationChangeEvent', () => {
1004
1005
ensureNoDisposablesAreLeakedInTestSuite();
1006
1007
test('changeEvent affecting keys with new configuration', () => {
1008
const configuration = new TestConfiguration(ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
1009
const change = configuration.compareAndUpdateLocalUserConfiguration(toConfigurationModel({
1010
'window.zoomLevel': 1,
1011
'workbench.editor.enablePreview': false,
1012
'files.autoSave': 'off',
1013
}));
1014
const testObject = new ConfigurationChangeEvent(change, undefined, configuration, undefined, new NullLogService());
1015
1016
assert.deepStrictEqual([...testObject.affectedKeys], ['window.zoomLevel', 'workbench.editor.enablePreview', 'files.autoSave']);
1017
1018
assert.ok(testObject.affectsConfiguration('window.zoomLevel'));
1019
assert.ok(testObject.affectsConfiguration('window'));
1020
1021
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview'));
1022
assert.ok(testObject.affectsConfiguration('workbench.editor'));
1023
assert.ok(testObject.affectsConfiguration('workbench'));
1024
1025
assert.ok(testObject.affectsConfiguration('files'));
1026
assert.ok(testObject.affectsConfiguration('files.autoSave'));
1027
assert.ok(!testObject.affectsConfiguration('files.exclude'));
1028
1029
assert.ok(!testObject.affectsConfiguration('[markdown]'));
1030
assert.ok(!testObject.affectsConfiguration('editor'));
1031
});
1032
1033
test('changeEvent affecting keys when configuration changed', () => {
1034
const configuration = new TestConfiguration(ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
1035
configuration.updateLocalUserConfiguration(toConfigurationModel({
1036
'window.zoomLevel': 2,
1037
'workbench.editor.enablePreview': true,
1038
'files.autoSave': 'off',
1039
}));
1040
const data = configuration.toData();
1041
const change = configuration.compareAndUpdateLocalUserConfiguration(toConfigurationModel({
1042
'window.zoomLevel': 1,
1043
'workbench.editor.enablePreview': false,
1044
'files.autoSave': 'off',
1045
}));
1046
const testObject = new ConfigurationChangeEvent(change, { data }, configuration, undefined, new NullLogService());
1047
1048
assert.deepStrictEqual([...testObject.affectedKeys], ['window.zoomLevel', 'workbench.editor.enablePreview']);
1049
1050
assert.ok(testObject.affectsConfiguration('window.zoomLevel'));
1051
assert.ok(testObject.affectsConfiguration('window'));
1052
1053
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview'));
1054
assert.ok(testObject.affectsConfiguration('workbench.editor'));
1055
assert.ok(testObject.affectsConfiguration('workbench'));
1056
1057
assert.ok(!testObject.affectsConfiguration('files'));
1058
assert.ok(!testObject.affectsConfiguration('[markdown]'));
1059
assert.ok(!testObject.affectsConfiguration('editor'));
1060
});
1061
1062
test('changeEvent affecting overrides with new configuration', () => {
1063
const configuration = new TestConfiguration(ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
1064
const change = configuration.compareAndUpdateLocalUserConfiguration(toConfigurationModel({
1065
'files.autoSave': 'off',
1066
'[markdown]': {
1067
'editor.wordWrap': 'off'
1068
},
1069
'[typescript][jsonc]': {
1070
'editor.lineNumbers': 'off'
1071
}
1072
}));
1073
const testObject = new ConfigurationChangeEvent(change, undefined, configuration, undefined, new NullLogService());
1074
1075
assert.deepStrictEqual([...testObject.affectedKeys], ['files.autoSave', '[markdown]', '[typescript][jsonc]', 'editor.wordWrap', 'editor.lineNumbers']);
1076
1077
assert.ok(testObject.affectsConfiguration('files'));
1078
assert.ok(testObject.affectsConfiguration('files.autoSave'));
1079
assert.ok(!testObject.affectsConfiguration('files.exclude'));
1080
1081
assert.ok(testObject.affectsConfiguration('[markdown]'));
1082
assert.ok(!testObject.affectsConfiguration('[markdown].editor'));
1083
assert.ok(!testObject.affectsConfiguration('[markdown].workbench'));
1084
1085
assert.ok(testObject.affectsConfiguration('editor'));
1086
assert.ok(testObject.affectsConfiguration('editor.wordWrap'));
1087
assert.ok(testObject.affectsConfiguration('editor.lineNumbers'));
1088
assert.ok(testObject.affectsConfiguration('editor', { overrideIdentifier: 'markdown' }));
1089
assert.ok(testObject.affectsConfiguration('editor', { overrideIdentifier: 'jsonc' }));
1090
assert.ok(testObject.affectsConfiguration('editor', { overrideIdentifier: 'typescript' }));
1091
assert.ok(testObject.affectsConfiguration('editor.wordWrap', { overrideIdentifier: 'markdown' }));
1092
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { overrideIdentifier: 'jsonc' }));
1093
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { overrideIdentifier: 'typescript' }));
1094
assert.ok(!testObject.affectsConfiguration('editor.lineNumbers', { overrideIdentifier: 'markdown' }));
1095
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { overrideIdentifier: 'typescript' }));
1096
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { overrideIdentifier: 'jsonc' }));
1097
assert.ok(!testObject.affectsConfiguration('editor', { overrideIdentifier: 'json' }));
1098
assert.ok(!testObject.affectsConfiguration('editor.fontSize', { overrideIdentifier: 'markdown' }));
1099
1100
assert.ok(!testObject.affectsConfiguration('editor.fontSize'));
1101
assert.ok(!testObject.affectsConfiguration('window'));
1102
});
1103
1104
test('changeEvent affecting overrides when configuration changed', () => {
1105
const configuration = new TestConfiguration(ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
1106
configuration.updateLocalUserConfiguration(toConfigurationModel({
1107
'workbench.editor.enablePreview': true,
1108
'[markdown]': {
1109
'editor.fontSize': 12,
1110
'editor.wordWrap': 'off'
1111
},
1112
'[css][scss]': {
1113
'editor.lineNumbers': 'off',
1114
'css.lint.emptyRules': 'error'
1115
},
1116
'files.autoSave': 'off',
1117
}));
1118
const data = configuration.toData();
1119
const change = configuration.compareAndUpdateLocalUserConfiguration(toConfigurationModel({
1120
'files.autoSave': 'off',
1121
'[markdown]': {
1122
'editor.fontSize': 13,
1123
'editor.wordWrap': 'off'
1124
},
1125
'[css][scss]': {
1126
'editor.lineNumbers': 'relative',
1127
'css.lint.emptyRules': 'error'
1128
},
1129
'window.zoomLevel': 1,
1130
}));
1131
const testObject = new ConfigurationChangeEvent(change, { data }, configuration, undefined, new NullLogService());
1132
1133
assert.deepStrictEqual([...testObject.affectedKeys], ['window.zoomLevel', '[markdown]', '[css][scss]', 'workbench.editor.enablePreview', 'editor.fontSize', 'editor.lineNumbers']);
1134
1135
assert.ok(!testObject.affectsConfiguration('files'));
1136
1137
assert.ok(testObject.affectsConfiguration('[markdown]'));
1138
assert.ok(!testObject.affectsConfiguration('[markdown].editor'));
1139
assert.ok(!testObject.affectsConfiguration('[markdown].editor.fontSize'));
1140
assert.ok(!testObject.affectsConfiguration('[markdown].editor.wordWrap'));
1141
assert.ok(!testObject.affectsConfiguration('[markdown].workbench'));
1142
assert.ok(testObject.affectsConfiguration('[css][scss]'));
1143
1144
assert.ok(testObject.affectsConfiguration('editor'));
1145
assert.ok(testObject.affectsConfiguration('editor', { overrideIdentifier: 'markdown' }));
1146
assert.ok(testObject.affectsConfiguration('editor', { overrideIdentifier: 'css' }));
1147
assert.ok(testObject.affectsConfiguration('editor', { overrideIdentifier: 'scss' }));
1148
assert.ok(testObject.affectsConfiguration('editor.fontSize', { overrideIdentifier: 'markdown' }));
1149
assert.ok(!testObject.affectsConfiguration('editor.fontSize', { overrideIdentifier: 'css' }));
1150
assert.ok(!testObject.affectsConfiguration('editor.fontSize', { overrideIdentifier: 'scss' }));
1151
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { overrideIdentifier: 'scss' }));
1152
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { overrideIdentifier: 'css' }));
1153
assert.ok(!testObject.affectsConfiguration('editor.lineNumbers', { overrideIdentifier: 'markdown' }));
1154
assert.ok(!testObject.affectsConfiguration('editor.wordWrap'));
1155
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { overrideIdentifier: 'markdown' }));
1156
assert.ok(!testObject.affectsConfiguration('editor', { overrideIdentifier: 'json' }));
1157
assert.ok(!testObject.affectsConfiguration('editor.fontSize', { overrideIdentifier: 'json' }));
1158
1159
assert.ok(testObject.affectsConfiguration('window'));
1160
assert.ok(testObject.affectsConfiguration('window.zoomLevel'));
1161
assert.ok(testObject.affectsConfiguration('window', { overrideIdentifier: 'markdown' }));
1162
assert.ok(testObject.affectsConfiguration('window.zoomLevel', { overrideIdentifier: 'markdown' }));
1163
1164
assert.ok(testObject.affectsConfiguration('workbench'));
1165
assert.ok(testObject.affectsConfiguration('workbench.editor'));
1166
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview'));
1167
assert.ok(testObject.affectsConfiguration('workbench', { overrideIdentifier: 'markdown' }));
1168
assert.ok(testObject.affectsConfiguration('workbench.editor', { overrideIdentifier: 'markdown' }));
1169
});
1170
1171
test('changeEvent affecting workspace folders', () => {
1172
const configuration = new TestConfiguration(ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
1173
configuration.updateWorkspaceConfiguration(toConfigurationModel({ 'window.title': 'custom' }));
1174
configuration.updateFolderConfiguration(URI.file('folder1'), toConfigurationModel({ 'window.zoomLevel': 2, 'window.restoreFullscreen': true }));
1175
configuration.updateFolderConfiguration(URI.file('folder2'), toConfigurationModel({ 'workbench.editor.enablePreview': true, 'window.restoreWindows': true }));
1176
const data = configuration.toData();
1177
const workspace = new Workspace('a', [new WorkspaceFolder({ index: 0, name: 'a', uri: URI.file('folder1') }), new WorkspaceFolder({ index: 1, name: 'b', uri: URI.file('folder2') }), new WorkspaceFolder({ index: 2, name: 'c', uri: URI.file('folder3') })]);
1178
const change = mergeChanges(
1179
configuration.compareAndUpdateWorkspaceConfiguration(toConfigurationModel({ 'window.title': 'native' })),
1180
configuration.compareAndUpdateFolderConfiguration(URI.file('folder1'), toConfigurationModel({ 'window.zoomLevel': 1, 'window.restoreFullscreen': false })),
1181
configuration.compareAndUpdateFolderConfiguration(URI.file('folder2'), toConfigurationModel({ 'workbench.editor.enablePreview': false, 'window.restoreWindows': false }))
1182
);
1183
const testObject = new ConfigurationChangeEvent(change, { data, workspace }, configuration, workspace, new NullLogService());
1184
1185
assert.deepStrictEqual([...testObject.affectedKeys], ['window.title', 'window.zoomLevel', 'window.restoreFullscreen', 'workbench.editor.enablePreview', 'window.restoreWindows']);
1186
1187
assert.ok(testObject.affectsConfiguration('window.zoomLevel'));
1188
assert.ok(testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file('folder1') }));
1189
assert.ok(testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file(join('folder1', 'file1')) }));
1190
assert.ok(!testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file('file1') }));
1191
assert.ok(!testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file('file2') }));
1192
assert.ok(!testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file(join('folder2', 'file2')) }));
1193
assert.ok(!testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file(join('folder3', 'file3')) }));
1194
1195
assert.ok(testObject.affectsConfiguration('window.restoreFullscreen'));
1196
assert.ok(testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file(join('folder1', 'file1')) }));
1197
assert.ok(testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file('folder1') }));
1198
assert.ok(!testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file('file1') }));
1199
assert.ok(!testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file('file2') }));
1200
assert.ok(!testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file(join('folder2', 'file2')) }));
1201
assert.ok(!testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file(join('folder3', 'file3')) }));
1202
1203
assert.ok(testObject.affectsConfiguration('window.restoreWindows'));
1204
assert.ok(testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file('folder2') }));
1205
assert.ok(testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file(join('folder2', 'file2')) }));
1206
assert.ok(!testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file('file2') }));
1207
assert.ok(!testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file(join('folder1', 'file1')) }));
1208
assert.ok(!testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file(join('folder3', 'file3')) }));
1209
1210
assert.ok(testObject.affectsConfiguration('window.title'));
1211
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('folder1') }));
1212
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file(join('folder1', 'file1')) }));
1213
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('folder2') }));
1214
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file(join('folder2', 'file2')) }));
1215
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('folder3') }));
1216
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file(join('folder3', 'file3')) }));
1217
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('file1') }));
1218
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('file2') }));
1219
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('file3') }));
1220
1221
assert.ok(testObject.affectsConfiguration('window'));
1222
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('folder1') }));
1223
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file(join('folder1', 'file1')) }));
1224
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('folder2') }));
1225
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file(join('folder2', 'file2')) }));
1226
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('folder3') }));
1227
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file(join('folder3', 'file3')) }));
1228
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('file1') }));
1229
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('file2') }));
1230
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('file3') }));
1231
1232
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview'));
1233
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file('folder2') }));
1234
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file(join('folder2', 'file2')) }));
1235
assert.ok(!testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file('folder1') }));
1236
assert.ok(!testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file(join('folder1', 'file1')) }));
1237
assert.ok(!testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file('folder3') }));
1238
1239
assert.ok(testObject.affectsConfiguration('workbench.editor'));
1240
assert.ok(testObject.affectsConfiguration('workbench.editor', { resource: URI.file('folder2') }));
1241
assert.ok(testObject.affectsConfiguration('workbench.editor', { resource: URI.file(join('folder2', 'file2')) }));
1242
assert.ok(!testObject.affectsConfiguration('workbench.editor', { resource: URI.file('folder1') }));
1243
assert.ok(!testObject.affectsConfiguration('workbench.editor', { resource: URI.file(join('folder1', 'file1')) }));
1244
assert.ok(!testObject.affectsConfiguration('workbench.editor', { resource: URI.file('folder3') }));
1245
1246
assert.ok(testObject.affectsConfiguration('workbench'));
1247
assert.ok(testObject.affectsConfiguration('workbench', { resource: URI.file('folder2') }));
1248
assert.ok(testObject.affectsConfiguration('workbench', { resource: URI.file(join('folder2', 'file2')) }));
1249
assert.ok(!testObject.affectsConfiguration('workbench', { resource: URI.file('folder1') }));
1250
assert.ok(!testObject.affectsConfiguration('workbench', { resource: URI.file('folder3') }));
1251
1252
assert.ok(!testObject.affectsConfiguration('files'));
1253
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file('folder1') }));
1254
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file(join('folder1', 'file1')) }));
1255
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file('folder2') }));
1256
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file(join('folder2', 'file2')) }));
1257
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file('folder3') }));
1258
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file(join('folder3', 'file3')) }));
1259
});
1260
1261
test('changeEvent - all', () => {
1262
const configuration = new TestConfiguration(ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
1263
configuration.updateFolderConfiguration(URI.file('file1'), toConfigurationModel({ 'window.zoomLevel': 2, 'window.restoreFullscreen': true }));
1264
const data = configuration.toData();
1265
const change = mergeChanges(
1266
configuration.compareAndUpdateDefaultConfiguration(toConfigurationModel({
1267
'editor.lineNumbers': 'off',
1268
'[markdown]': {
1269
'editor.wordWrap': 'off'
1270
}
1271
}), ['editor.lineNumbers', '[markdown]']),
1272
configuration.compareAndUpdateLocalUserConfiguration(toConfigurationModel({
1273
'[json]': {
1274
'editor.lineNumbers': 'relative'
1275
}
1276
})),
1277
configuration.compareAndUpdateWorkspaceConfiguration(toConfigurationModel({ 'window.title': 'custom' })),
1278
configuration.compareAndDeleteFolderConfiguration(URI.file('file1')),
1279
configuration.compareAndUpdateFolderConfiguration(URI.file('file2'), toConfigurationModel({ 'workbench.editor.enablePreview': true, 'window.restoreWindows': true })));
1280
const workspace = new Workspace('a', [new WorkspaceFolder({ index: 0, name: 'a', uri: URI.file('file1') }), new WorkspaceFolder({ index: 1, name: 'b', uri: URI.file('file2') }), new WorkspaceFolder({ index: 2, name: 'c', uri: URI.file('folder3') })]);
1281
const testObject = new ConfigurationChangeEvent(change, { data, workspace }, configuration, workspace, new NullLogService());
1282
1283
assert.deepStrictEqual([...testObject.affectedKeys], ['editor.lineNumbers', '[markdown]', '[json]', 'window.title', 'window.zoomLevel', 'window.restoreFullscreen', 'workbench.editor.enablePreview', 'window.restoreWindows', 'editor.wordWrap']);
1284
1285
assert.ok(testObject.affectsConfiguration('window.title'));
1286
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('file1') }));
1287
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('file2') }));
1288
1289
assert.ok(testObject.affectsConfiguration('window'));
1290
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('file1') }));
1291
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('file2') }));
1292
1293
assert.ok(testObject.affectsConfiguration('window.zoomLevel'));
1294
assert.ok(testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file('file1') }));
1295
assert.ok(!testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file('file2') }));
1296
1297
assert.ok(testObject.affectsConfiguration('window.restoreFullscreen'));
1298
assert.ok(testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file('file1') }));
1299
assert.ok(!testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file('file2') }));
1300
1301
assert.ok(testObject.affectsConfiguration('window.restoreWindows'));
1302
assert.ok(testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file('file2') }));
1303
assert.ok(!testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file('file1') }));
1304
1305
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview'));
1306
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file('file2') }));
1307
assert.ok(!testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file('file1') }));
1308
1309
assert.ok(testObject.affectsConfiguration('workbench.editor'));
1310
assert.ok(testObject.affectsConfiguration('workbench.editor', { resource: URI.file('file2') }));
1311
assert.ok(!testObject.affectsConfiguration('workbench.editor', { resource: URI.file('file1') }));
1312
1313
assert.ok(testObject.affectsConfiguration('workbench'));
1314
assert.ok(testObject.affectsConfiguration('workbench', { resource: URI.file('file2') }));
1315
assert.ok(!testObject.affectsConfiguration('workbench', { resource: URI.file('file1') }));
1316
1317
assert.ok(!testObject.affectsConfiguration('files'));
1318
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file('file1') }));
1319
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file('file2') }));
1320
1321
assert.ok(testObject.affectsConfiguration('editor'));
1322
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file1') }));
1323
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file2') }));
1324
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file1'), overrideIdentifier: 'json' }));
1325
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file1'), overrideIdentifier: 'markdown' }));
1326
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file1'), overrideIdentifier: 'typescript' }));
1327
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file2'), overrideIdentifier: 'json' }));
1328
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file2'), overrideIdentifier: 'markdown' }));
1329
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file2'), overrideIdentifier: 'typescript' }));
1330
1331
assert.ok(testObject.affectsConfiguration('editor.lineNumbers'));
1332
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file1') }));
1333
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file2') }));
1334
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file1'), overrideIdentifier: 'json' }));
1335
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file1'), overrideIdentifier: 'markdown' }));
1336
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file1'), overrideIdentifier: 'typescript' }));
1337
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file2'), overrideIdentifier: 'json' }));
1338
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file2'), overrideIdentifier: 'markdown' }));
1339
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file2'), overrideIdentifier: 'typescript' }));
1340
1341
assert.ok(testObject.affectsConfiguration('editor.wordWrap'));
1342
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file1') }));
1343
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file2') }));
1344
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file1'), overrideIdentifier: 'json' }));
1345
assert.ok(testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file1'), overrideIdentifier: 'markdown' }));
1346
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file1'), overrideIdentifier: 'typescript' }));
1347
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file2'), overrideIdentifier: 'json' }));
1348
assert.ok(testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file2'), overrideIdentifier: 'markdown' }));
1349
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file2'), overrideIdentifier: 'typescript' }));
1350
1351
assert.ok(!testObject.affectsConfiguration('editor.fontSize'));
1352
assert.ok(!testObject.affectsConfiguration('editor.fontSize', { resource: URI.file('file1') }));
1353
assert.ok(!testObject.affectsConfiguration('editor.fontSize', { resource: URI.file('file2') }));
1354
});
1355
1356
test('changeEvent affecting tasks and launches', () => {
1357
const configuration = new TestConfiguration(ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
1358
const change = configuration.compareAndUpdateLocalUserConfiguration(toConfigurationModel({
1359
'launch': {
1360
'configuraiton': {}
1361
},
1362
'launch.version': 1,
1363
'tasks': {
1364
'version': 2
1365
}
1366
}));
1367
const testObject = new ConfigurationChangeEvent(change, undefined, configuration, undefined, new NullLogService());
1368
1369
assert.deepStrictEqual([...testObject.affectedKeys], ['launch', 'launch.version', 'tasks']);
1370
assert.ok(testObject.affectsConfiguration('launch'));
1371
assert.ok(testObject.affectsConfiguration('launch.version'));
1372
assert.ok(testObject.affectsConfiguration('tasks'));
1373
});
1374
1375
test('affectsConfiguration returns false for empty string', () => {
1376
const configuration = new TestConfiguration(ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()), ConfigurationModel.createEmptyModel(new NullLogService()));
1377
const change = configuration.compareAndUpdateLocalUserConfiguration(toConfigurationModel({ 'window.zoomLevel': 1 }));
1378
const testObject = new ConfigurationChangeEvent(change, undefined, configuration, undefined, new NullLogService());
1379
1380
assert.strictEqual(false, testObject.affectsConfiguration(''));
1381
});
1382
1383
});
1384
1385
suite('Configuration.Parse', () => {
1386
1387
const logService = new NullLogService();
1388
ensureNoDisposablesAreLeakedInTestSuite();
1389
1390
test('parsing configuration only with local user configuration and raw is same', () => {
1391
const configuration = new TestConfiguration(
1392
ConfigurationModel.createEmptyModel(logService),
1393
ConfigurationModel.createEmptyModel(logService),
1394
ConfigurationModel.createEmptyModel(logService),
1395
new ConfigurationModel({ 'a': 1, 'c': 1 }, ['a', 'c'], [{ identifiers: ['x', 'y'], contents: { 'a': 2, 'b': 1 }, keys: ['a'] }], undefined, logService)
1396
);
1397
1398
const actual = Configuration.parse(configuration.toData(), logService);
1399
1400
assert.deepStrictEqual(actual.inspect('a', {}, undefined).userLocal, { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1401
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).userLocal, { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1402
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'x' }, undefined).userLocal, { value: undefined, override: 1, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 1 }] });
1403
assert.deepStrictEqual(actual.inspect('d', {}, undefined).userLocal, undefined);
1404
1405
assert.deepStrictEqual(actual.inspect('a', {}, undefined).userRemote, undefined);
1406
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).userRemote, undefined);
1407
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'x' }, undefined).userRemote, undefined);
1408
assert.deepStrictEqual(actual.inspect('d', {}, undefined).userRemote, undefined);
1409
1410
assert.deepStrictEqual(actual.inspect('a', {}, undefined).user, { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1411
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).user, { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1412
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'x' }, undefined).user, { value: undefined, override: 1, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 1 }] });
1413
assert.deepStrictEqual(actual.inspect('d', {}, undefined).user, undefined);
1414
});
1415
1416
test('parsing configuration only with local user configuration and raw is not same', () => {
1417
const configuration = new TestConfiguration(
1418
ConfigurationModel.createEmptyModel(logService),
1419
ConfigurationModel.createEmptyModel(logService),
1420
ConfigurationModel.createEmptyModel(logService),
1421
new ConfigurationModel({ 'a': 1, 'c': 1 }, ['a', 'c'], [{ identifiers: ['x', 'y'], contents: { 'a': 2, }, keys: ['a'] }], {
1422
'a': 1,
1423
'b': 2,
1424
'c': 1,
1425
'd': 3,
1426
'[x][y]': {
1427
'a': 2,
1428
'b': 1
1429
}
1430
}, logService)
1431
);
1432
1433
const actual = Configuration.parse(configuration.toData(), logService);
1434
1435
assert.deepStrictEqual(actual.inspect('a', {}, undefined).userLocal, { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1436
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).userLocal, { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1437
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'x' }, undefined).userLocal, { value: 2, override: 1, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 1 }] });
1438
assert.deepStrictEqual(actual.inspect('d', {}, undefined).userLocal, { value: 3, override: undefined, merged: 3, overrides: undefined });
1439
assert.deepStrictEqual(actual.inspect('e', {}, undefined).userLocal, undefined);
1440
1441
assert.deepStrictEqual(actual.inspect('a', {}, undefined).userRemote, undefined);
1442
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).userRemote, undefined);
1443
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'x' }, undefined).userRemote, undefined);
1444
assert.deepStrictEqual(actual.inspect('d', {}, undefined).userRemote, undefined);
1445
assert.deepStrictEqual(actual.inspect('e', {}, undefined).userRemote, undefined);
1446
1447
assert.deepStrictEqual(actual.inspect('a', {}, undefined).user, { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1448
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).user, { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1449
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'x' }, undefined).user, { value: 2, override: 1, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 1 }] });
1450
assert.deepStrictEqual(actual.inspect('d', {}, undefined).user, { value: 3, override: undefined, merged: 3, overrides: undefined });
1451
assert.deepStrictEqual(actual.inspect('e', {}, undefined).user, undefined);
1452
});
1453
1454
test('parsing configuration with local and remote user configuration and raw is same for both', () => {
1455
const configuration = new TestConfiguration(
1456
ConfigurationModel.createEmptyModel(logService),
1457
ConfigurationModel.createEmptyModel(logService),
1458
ConfigurationModel.createEmptyModel(logService),
1459
new ConfigurationModel({ 'a': 1 }, ['a'], [{ identifiers: ['x', 'y'], contents: { 'a': 2, }, keys: ['a'] }], undefined, logService),
1460
new ConfigurationModel({ 'b': 3 }, ['b'], [], undefined, logService)
1461
);
1462
1463
const actual = Configuration.parse(configuration.toData(), logService);
1464
1465
assert.deepStrictEqual(actual.inspect('a', {}, undefined).userLocal, { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1466
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).userLocal, { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1467
assert.deepStrictEqual(actual.inspect('b', {}, undefined).userLocal, undefined);
1468
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'y' }, undefined).userLocal, undefined);
1469
assert.deepStrictEqual(actual.inspect('c', {}, undefined).userLocal, undefined);
1470
1471
assert.deepStrictEqual(actual.inspect('a', {}, undefined).userRemote, undefined);
1472
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).userRemote, undefined);
1473
assert.deepStrictEqual(actual.inspect('b', {}, undefined).userRemote, { value: 3, override: undefined, merged: 3, overrides: undefined });
1474
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'y' }, undefined).userRemote, { value: 3, override: undefined, merged: 3, overrides: undefined });
1475
assert.deepStrictEqual(actual.inspect('c', {}, undefined).userRemote, undefined);
1476
1477
assert.deepStrictEqual(actual.inspect('a', {}, undefined).user, { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1478
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).user, { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1479
assert.deepStrictEqual(actual.inspect('b', {}, undefined).user, { value: 3, override: undefined, merged: 3, overrides: undefined });
1480
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'y' }, undefined).user, { value: 3, override: undefined, merged: 3, overrides: undefined });
1481
assert.deepStrictEqual(actual.inspect('c', {}, undefined).user, undefined);
1482
});
1483
1484
test('parsing configuration with local and remote user configuration and raw is not same for local user', () => {
1485
const configuration = new TestConfiguration(
1486
ConfigurationModel.createEmptyModel(logService),
1487
ConfigurationModel.createEmptyModel(logService),
1488
ConfigurationModel.createEmptyModel(logService),
1489
new ConfigurationModel({ 'a': 1 }, ['a'], [{ identifiers: ['x', 'y'], contents: { 'a': 2, }, keys: ['a'] }], {
1490
'a': 1,
1491
'b': 2,
1492
'c': 3,
1493
'[x][y]': {
1494
'a': 2,
1495
'b': 4,
1496
}
1497
}, logService),
1498
new ConfigurationModel({ 'b': 3 }, ['b'], [], undefined, logService)
1499
);
1500
1501
const actual = Configuration.parse(configuration.toData(), logService);
1502
1503
assert.deepStrictEqual(actual.inspect('a', {}, undefined).userLocal, { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1504
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).userLocal, { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1505
assert.deepStrictEqual(actual.inspect('b', {}, undefined).userLocal, { value: 2, override: undefined, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 4 }] });
1506
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'y' }, undefined).userLocal, { value: 2, override: 4, merged: 4, overrides: [{ identifiers: ['x', 'y'], value: 4 }] });
1507
assert.deepStrictEqual(actual.inspect('c', {}, undefined).userLocal, { value: 3, override: undefined, merged: 3, overrides: undefined });
1508
1509
assert.deepStrictEqual(actual.inspect('a', {}, undefined).userRemote, undefined);
1510
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).userRemote, undefined);
1511
assert.deepStrictEqual(actual.inspect('b', {}, undefined).userRemote, { value: 3, override: undefined, merged: 3, overrides: undefined });
1512
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'y' }, undefined).userRemote, { value: 3, override: undefined, merged: 3, overrides: undefined });
1513
assert.deepStrictEqual(actual.inspect('c', {}, undefined).userRemote, undefined);
1514
1515
assert.deepStrictEqual(actual.inspect('a', {}, undefined).user, { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1516
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).user, { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1517
assert.deepStrictEqual(actual.inspect('b', {}, undefined).user, { value: 3, merged: 3, override: undefined, overrides: undefined });
1518
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'y' }, undefined).user, { value: 3, override: undefined, merged: 3, overrides: undefined });
1519
assert.deepStrictEqual(actual.inspect('c', {}, undefined).user, undefined);
1520
});
1521
1522
test('parsing configuration with local and remote user configuration and raw is not same for remote user', () => {
1523
const configuration = new TestConfiguration(
1524
ConfigurationModel.createEmptyModel(logService),
1525
ConfigurationModel.createEmptyModel(logService),
1526
ConfigurationModel.createEmptyModel(logService),
1527
new ConfigurationModel({ 'b': 3 }, ['b'], [], undefined, logService),
1528
new ConfigurationModel({ 'a': 1 }, ['a'], [{ identifiers: ['x', 'y'], contents: { 'a': 2, }, keys: ['a'] }], {
1529
'a': 1,
1530
'b': 2,
1531
'c': 3,
1532
'[x][y]': {
1533
'a': 2,
1534
'b': 4,
1535
}
1536
}, logService),
1537
);
1538
1539
const actual = Configuration.parse(configuration.toData(), logService);
1540
1541
assert.deepStrictEqual(actual.inspect('a', {}, undefined).userLocal, undefined);
1542
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).userLocal, undefined);
1543
assert.deepStrictEqual(actual.inspect('b', {}, undefined).userLocal, { value: 3, override: undefined, merged: 3, overrides: undefined });
1544
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'y' }, undefined).userLocal, { value: 3, override: undefined, merged: 3, overrides: undefined });
1545
assert.deepStrictEqual(actual.inspect('c', {}, undefined).userLocal, undefined);
1546
1547
assert.deepStrictEqual(actual.inspect('a', {}, undefined).userRemote, { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1548
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).userRemote, { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1549
assert.deepStrictEqual(actual.inspect('b', {}, undefined).userRemote, { value: 2, override: undefined, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 4 }] });
1550
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'y' }, undefined).userRemote, { value: 2, override: 4, merged: 4, overrides: [{ identifiers: ['x', 'y'], value: 4 }] });
1551
assert.deepStrictEqual(actual.inspect('c', {}, undefined).userRemote, { value: 3, override: undefined, merged: 3, overrides: undefined });
1552
1553
assert.deepStrictEqual(actual.inspect('a', {}, undefined).user, { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1554
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).user, { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1555
assert.deepStrictEqual(actual.inspect('b', {}, undefined).user, { value: 3, override: undefined, merged: 3, overrides: undefined });
1556
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'y' }, undefined).user, { value: 3, override: undefined, merged: 3, overrides: undefined });
1557
assert.deepStrictEqual(actual.inspect('c', {}, undefined).user, undefined);
1558
});
1559
1560
test('parsing configuration with local and remote user configuration and raw is not same for both', () => {
1561
const configuration = new TestConfiguration(
1562
ConfigurationModel.createEmptyModel(logService),
1563
ConfigurationModel.createEmptyModel(logService),
1564
ConfigurationModel.createEmptyModel(logService),
1565
new ConfigurationModel({ 'b': 3 }, ['b'], [], {
1566
'a': 4,
1567
'b': 3
1568
}, logService),
1569
new ConfigurationModel({ 'a': 1 }, ['a'], [{ identifiers: ['x', 'y'], contents: { 'a': 2, }, keys: ['a'] }], {
1570
'a': 1,
1571
'b': 2,
1572
'c': 3,
1573
'[x][y]': {
1574
'a': 2,
1575
'b': 4,
1576
}
1577
}, logService),
1578
);
1579
1580
const actual = Configuration.parse(configuration.toData(), logService);
1581
1582
assert.deepStrictEqual(actual.inspect('a', {}, undefined).userLocal, { value: 4, override: undefined, merged: 4, overrides: undefined });
1583
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).userLocal, { value: 4, override: undefined, merged: 4, overrides: undefined });
1584
assert.deepStrictEqual(actual.inspect('b', {}, undefined).userLocal, { value: 3, override: undefined, merged: 3, overrides: undefined });
1585
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'y' }, undefined).userLocal, { value: 3, override: undefined, merged: 3, overrides: undefined });
1586
assert.deepStrictEqual(actual.inspect('c', {}, undefined).userLocal, undefined);
1587
1588
assert.deepStrictEqual(actual.inspect('a', {}, undefined).userRemote, { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1589
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).userRemote, { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1590
assert.deepStrictEqual(actual.inspect('b', {}, undefined).userRemote, { value: 2, override: undefined, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 4 }] });
1591
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'y' }, undefined).userRemote, { value: 2, override: 4, merged: 4, overrides: [{ identifiers: ['x', 'y'], value: 4 }] });
1592
assert.deepStrictEqual(actual.inspect('c', {}, undefined).userRemote, { value: 3, override: undefined, merged: 3, overrides: undefined });
1593
1594
assert.deepStrictEqual(actual.inspect('a', {}, undefined).user, { value: 1, override: undefined, merged: 1, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1595
assert.deepStrictEqual(actual.inspect('a', { overrideIdentifier: 'x' }, undefined).user, { value: 1, override: 2, merged: 2, overrides: [{ identifiers: ['x', 'y'], value: 2 }] });
1596
assert.deepStrictEqual(actual.inspect('b', {}, undefined).user, { value: 3, override: undefined, merged: 3, overrides: undefined });
1597
assert.deepStrictEqual(actual.inspect('b', { overrideIdentifier: 'y' }, undefined).user, { value: 3, override: undefined, merged: 3, overrides: undefined });
1598
assert.deepStrictEqual(actual.inspect('c', {}, undefined).user, undefined);
1599
});
1600
1601
1602
});
1603
1604
function toConfigurationModel(obj: any): ConfigurationModel {
1605
const parser = new ConfigurationModelParser('test', new NullLogService());
1606
parser.parse(JSON.stringify(obj));
1607
return parser.configurationModel;
1608
}
1609
1610