@theia/plugin-ext 1.28.0 → 1.29.0-next.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/plugin-api-rpc-model.d.ts +7 -0
- package/lib/common/plugin-api-rpc-model.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc-model.js.map +1 -1
- package/lib/common/plugin-api-rpc.d.ts +15 -9
- package/lib/common/plugin-api-rpc.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc.js.map +1 -1
- package/lib/common/rpc-protocol.d.ts +1 -1
- package/lib/common/rpc-protocol.d.ts.map +1 -1
- package/lib/common/rpc-protocol.js +3 -3
- package/lib/common/rpc-protocol.js.map +1 -1
- package/lib/main/browser/languages-main.d.ts +6 -1
- package/lib/main/browser/languages-main.d.ts.map +1 -1
- package/lib/main/browser/languages-main.js +15 -1
- package/lib/main/browser/languages-main.js.map +1 -1
- package/lib/main/browser/preference-registry-main.d.ts +4 -3
- package/lib/main/browser/preference-registry-main.d.ts.map +1 -1
- package/lib/main/browser/preference-registry-main.js +26 -14
- package/lib/main/browser/preference-registry-main.js.map +1 -1
- package/lib/main/browser/view/tree-view-decorator-service.d.ts +1 -1
- package/lib/main/browser/view/tree-view-decorator-service.d.ts.map +1 -1
- package/lib/main/browser/view/tree-view-decorator-service.js +1 -1
- package/lib/main/browser/view/tree-view-decorator-service.js.map +1 -1
- package/lib/main/browser/workspace-main.d.ts.map +1 -1
- package/lib/main/browser/workspace-main.js +1 -4
- package/lib/main/browser/workspace-main.js.map +1 -1
- package/lib/plugin/languages/code-action.d.ts.map +1 -1
- package/lib/plugin/languages/code-action.js +8 -9
- package/lib/plugin/languages/code-action.js.map +1 -1
- package/lib/plugin/languages/document-highlight.d.ts.map +1 -1
- package/lib/plugin/languages/document-highlight.js +0 -1
- package/lib/plugin/languages/document-highlight.js.map +1 -1
- package/lib/plugin/languages/evaluatable-expression.d.ts +12 -0
- package/lib/plugin/languages/evaluatable-expression.d.ts.map +1 -0
- package/lib/plugin/languages/evaluatable-expression.js +41 -0
- package/lib/plugin/languages/evaluatable-expression.js.map +1 -0
- package/lib/plugin/languages/util.d.ts +2 -2
- package/lib/plugin/languages/util.d.ts.map +1 -1
- package/lib/plugin/languages/util.js +0 -2
- package/lib/plugin/languages/util.js.map +1 -1
- package/lib/plugin/languages.d.ts +3 -1
- package/lib/plugin/languages.d.ts.map +1 -1
- package/lib/plugin/languages.js +11 -0
- package/lib/plugin/languages.js.map +1 -1
- package/lib/plugin/plugin-context.d.ts.map +1 -1
- package/lib/plugin/plugin-context.js +4 -0
- package/lib/plugin/plugin-context.js.map +1 -1
- package/lib/plugin/plugin-storage.d.ts +1 -0
- package/lib/plugin/plugin-storage.d.ts.map +1 -1
- package/lib/plugin/plugin-storage.js +3 -0
- package/lib/plugin/plugin-storage.js.map +1 -1
- package/lib/plugin/preference-registry.d.ts +15 -2
- package/lib/plugin/preference-registry.d.ts.map +1 -1
- package/lib/plugin/preference-registry.js +105 -62
- package/lib/plugin/preference-registry.js.map +1 -1
- package/lib/plugin/preference-registry.spec.js +207 -35
- package/lib/plugin/preference-registry.spec.js.map +1 -1
- package/lib/plugin/type-converters.d.ts +7 -6
- package/lib/plugin/type-converters.d.ts.map +1 -1
- package/lib/plugin/type-converters.js +54 -55
- package/lib/plugin/type-converters.js.map +1 -1
- package/lib/plugin/types-impl.d.ts +8 -3
- package/lib/plugin/types-impl.d.ts.map +1 -1
- package/lib/plugin/types-impl.js +22 -10
- package/lib/plugin/types-impl.js.map +1 -1
- package/package.json +24 -24
- package/src/common/plugin-api-rpc-model.ts +10 -0
- package/src/common/plugin-api-rpc.ts +18 -9
- package/src/common/rpc-protocol.ts +5 -5
- package/src/main/browser/languages-main.ts +23 -1
- package/src/main/browser/preference-registry-main.ts +23 -14
- package/src/main/browser/view/tree-view-decorator-service.ts +2 -2
- package/src/main/browser/workspace-main.ts +1 -5
- package/src/plugin/languages/code-action.ts +9 -12
- package/src/plugin/languages/document-highlight.ts +1 -2
- package/src/plugin/languages/evaluatable-expression.ts +47 -0
- package/src/plugin/languages/util.ts +2 -4
- package/src/plugin/languages.ts +15 -0
- package/src/plugin/plugin-context.ts +6 -1
- package/src/plugin/plugin-storage.ts +4 -0
- package/src/plugin/preference-registry.spec.ts +247 -39
- package/src/plugin/preference-registry.ts +107 -71
- package/src/plugin/type-converters.ts +58 -59
- package/src/plugin/types-impl.ts +30 -14
- package/lib/plugin/preferences/configuration.d.ts +0 -35
- package/lib/plugin/preferences/configuration.d.ts.map +0 -1
- package/lib/plugin/preferences/configuration.js +0 -137
- package/lib/plugin/preferences/configuration.js.map +0 -1
- package/lib/plugin/preferences/configuration.spec.d.ts +0 -2
- package/lib/plugin/preferences/configuration.spec.d.ts.map +0 -1
- package/lib/plugin/preferences/configuration.spec.js +0 -178
- package/lib/plugin/preferences/configuration.spec.js.map +0 -1
- package/src/plugin/preferences/configuration.spec.ts +0 -292
- package/src/plugin/preferences/configuration.ts +0 -167
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.ConfigurationModel = exports.Configuration = void 0;
|
|
19
|
-
const types_1 = require("../../common/types");
|
|
20
|
-
const cloneDeep = require("lodash.clonedeep");
|
|
21
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
22
|
-
class Configuration {
|
|
23
|
-
constructor(defaultConfiguration, userConfiguration, workspaceConfiguration = new ConfigurationModel(), folderConfigurations = {}) {
|
|
24
|
-
this.defaultConfiguration = defaultConfiguration;
|
|
25
|
-
this.userConfiguration = userConfiguration;
|
|
26
|
-
this.workspaceConfiguration = workspaceConfiguration;
|
|
27
|
-
this.folderConfigurations = folderConfigurations;
|
|
28
|
-
this.folderCombinedConfigs = {};
|
|
29
|
-
}
|
|
30
|
-
getValue(section, workspace, resource) {
|
|
31
|
-
return this.getCombinedResourceConfig(workspace, resource).getValue(section);
|
|
32
|
-
}
|
|
33
|
-
inspect(key, workspace, resource) {
|
|
34
|
-
const combinedConfiguration = this.getCombinedResourceConfig(workspace, resource);
|
|
35
|
-
const folderConfiguration = this.getFolderResourceConfig(workspace, resource);
|
|
36
|
-
return {
|
|
37
|
-
default: this.defaultConfiguration.getValue(key),
|
|
38
|
-
user: this.userConfiguration.getValue(key),
|
|
39
|
-
workspace: workspace ? this.workspaceConfiguration.getValue(key) : undefined,
|
|
40
|
-
workspaceFolder: folderConfiguration ? folderConfiguration.getValue(key) : undefined,
|
|
41
|
-
value: combinedConfiguration.getValue(key)
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
getCombinedResourceConfig(workspace, resource) {
|
|
45
|
-
const combinedConfig = this.getCombinedConfig();
|
|
46
|
-
if (!workspace || !resource) {
|
|
47
|
-
return combinedConfig;
|
|
48
|
-
}
|
|
49
|
-
const workspaceFolder = workspace.getWorkspaceFolder(resource);
|
|
50
|
-
if (!workspaceFolder) {
|
|
51
|
-
return combinedConfig;
|
|
52
|
-
}
|
|
53
|
-
return this.getFolderCombinedConfig(workspaceFolder.uri.toString()) || combinedConfig;
|
|
54
|
-
}
|
|
55
|
-
getCombinedConfig() {
|
|
56
|
-
if (!this.combinedConfig) {
|
|
57
|
-
this.combinedConfig = this.defaultConfiguration.merge(this.userConfiguration, this.workspaceConfiguration);
|
|
58
|
-
}
|
|
59
|
-
return this.combinedConfig;
|
|
60
|
-
}
|
|
61
|
-
getFolderCombinedConfig(folder) {
|
|
62
|
-
if (this.folderCombinedConfigs[folder]) {
|
|
63
|
-
return this.folderCombinedConfigs[folder];
|
|
64
|
-
}
|
|
65
|
-
const combinedConfig = this.getCombinedConfig();
|
|
66
|
-
const folderConfig = this.folderConfigurations[folder];
|
|
67
|
-
if (!folderConfig) {
|
|
68
|
-
return combinedConfig;
|
|
69
|
-
}
|
|
70
|
-
const folderCombinedConfig = combinedConfig.merge(folderConfig);
|
|
71
|
-
this.folderCombinedConfigs[folder] = folderCombinedConfig;
|
|
72
|
-
return folderCombinedConfig;
|
|
73
|
-
}
|
|
74
|
-
getFolderResourceConfig(workspace, resource) {
|
|
75
|
-
if (!workspace || !resource) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const workspaceFolder = workspace.getWorkspaceFolder(resource);
|
|
79
|
-
if (!workspaceFolder) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
return this.folderConfigurations[workspaceFolder.uri.toString()];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
exports.Configuration = Configuration;
|
|
86
|
-
class ConfigurationModel {
|
|
87
|
-
constructor(contents = Object.create(null), keys = []) {
|
|
88
|
-
this.contents = contents;
|
|
89
|
-
this.keys = keys;
|
|
90
|
-
}
|
|
91
|
-
getValue(section) {
|
|
92
|
-
if (!section) {
|
|
93
|
-
return this.contents;
|
|
94
|
-
}
|
|
95
|
-
const path = section.split('.');
|
|
96
|
-
let current = this.contents;
|
|
97
|
-
for (let i = 0; i < path.length; i++) {
|
|
98
|
-
if (typeof current !== 'object' || current === null) {
|
|
99
|
-
return undefined;
|
|
100
|
-
}
|
|
101
|
-
current = current[path[i]];
|
|
102
|
-
}
|
|
103
|
-
return current;
|
|
104
|
-
}
|
|
105
|
-
merge(...others) {
|
|
106
|
-
const contents = cloneDeep(this.contents);
|
|
107
|
-
const allKeys = [...this.keys];
|
|
108
|
-
for (const other of others) {
|
|
109
|
-
this.mergeContents(contents, other.contents);
|
|
110
|
-
this.mergeKeys(allKeys, other.keys);
|
|
111
|
-
}
|
|
112
|
-
return new ConfigurationModel(contents, allKeys);
|
|
113
|
-
}
|
|
114
|
-
mergeContents(source, target) {
|
|
115
|
-
for (const key of Object.keys(target)) {
|
|
116
|
-
if (key === '__proto__') {
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
if (key in source) {
|
|
120
|
-
if ((0, types_1.isObject)(source[key]) && (0, types_1.isObject)(target[key])) {
|
|
121
|
-
this.mergeContents(source[key], target[key]);
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
source[key] = cloneDeep(target[key]);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
mergeKeys(source, target) {
|
|
129
|
-
for (const key of target) {
|
|
130
|
-
if (source.indexOf(key) === -1) {
|
|
131
|
-
source.push(key);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
exports.ConfigurationModel = ConfigurationModel;
|
|
137
|
-
//# sourceMappingURL=configuration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/plugin/preferences/configuration.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;AAGhF,8CAA8C;AAC9C,8CAA+C;AAG/C,uDAAuD;AAEvD,MAAa,aAAa;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IAAI,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAEO,aAAa,CAAC,MAAW,EAAE,MAAW;QAC1C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;YACnC,IAAI,GAAG,KAAK,WAAW,EAAE;gBACrB,SAAS;aACZ;YACD,IAAI,GAAG,IAAI,MAAM,EAAE;gBACf,IAAI,IAAA,gBAAQ,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,IAAA,gBAAQ,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;oBAChD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC7C,SAAS;iBACZ;aACJ;YACD,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;SACxC;IACL,CAAC;IAEO,SAAS,CAAC,MAAgB,EAAE,MAAgB;QAChD,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;YACtB,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC5B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACpB;SACJ;IACL,CAAC;CAEJ;AAzDD,gDAyDC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.spec.d.ts","sourceRoot":"","sources":["../../../src/plugin/preferences/configuration.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
19
|
-
const chai = require("chai");
|
|
20
|
-
const configuration_1 = require("./configuration");
|
|
21
|
-
const preference_scope_1 = require("@theia/core/lib/common/preferences/preference-scope");
|
|
22
|
-
const vscode_uri_1 = require("@theia/core/shared/vscode-uri");
|
|
23
|
-
const expect = chai.expect;
|
|
24
|
-
let inspect;
|
|
25
|
-
const projects = ['/projects/workspace/project1', '/projects/workspace/project2'];
|
|
26
|
-
const propertyName = 'tabSize';
|
|
27
|
-
const preferences = {
|
|
28
|
-
[preference_scope_1.PreferenceScope.Default]: {
|
|
29
|
-
[propertyName]: 6,
|
|
30
|
-
},
|
|
31
|
-
[preference_scope_1.PreferenceScope.User]: {
|
|
32
|
-
[propertyName]: 5
|
|
33
|
-
},
|
|
34
|
-
[preference_scope_1.PreferenceScope.Workspace]: {
|
|
35
|
-
[propertyName]: 4
|
|
36
|
-
},
|
|
37
|
-
[preference_scope_1.PreferenceScope.Folder]: {
|
|
38
|
-
[projects[0]]: {
|
|
39
|
-
[propertyName]: 3
|
|
40
|
-
},
|
|
41
|
-
[projects[1]]: {
|
|
42
|
-
[propertyName]: 2
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const workspace = {};
|
|
47
|
-
let configuration;
|
|
48
|
-
let defaultConfiguration;
|
|
49
|
-
let userConfiguration;
|
|
50
|
-
let workspaceConfiguration;
|
|
51
|
-
let folderConfigurations;
|
|
52
|
-
before(() => {
|
|
53
|
-
workspace.getWorkspaceFolder = (uri => {
|
|
54
|
-
const name = uri.toString().replace(/[^\/]+$/, '$1');
|
|
55
|
-
const index = projects.indexOf(uri.toString());
|
|
56
|
-
return { uri, name, index };
|
|
57
|
-
});
|
|
58
|
-
defaultConfiguration = new configuration_1.ConfigurationModel(preferences[preference_scope_1.PreferenceScope.Default], Object.keys(preferences[preference_scope_1.PreferenceScope.Default]));
|
|
59
|
-
userConfiguration = new configuration_1.ConfigurationModel(preferences[preference_scope_1.PreferenceScope.User], Object.keys(preferences[preference_scope_1.PreferenceScope.User]));
|
|
60
|
-
workspaceConfiguration = new configuration_1.ConfigurationModel(preferences[preference_scope_1.PreferenceScope.Workspace], Object.keys(preferences[preference_scope_1.PreferenceScope.Workspace]));
|
|
61
|
-
folderConfigurations = projects.reduce((configurations, project) => {
|
|
62
|
-
const folderPrefs = preferences[preference_scope_1.PreferenceScope.Folder][project];
|
|
63
|
-
configurations[project] = new configuration_1.ConfigurationModel(folderPrefs, Object.keys(folderPrefs));
|
|
64
|
-
return configurations;
|
|
65
|
-
}, {});
|
|
66
|
-
});
|
|
67
|
-
describe('Configuration:', () => {
|
|
68
|
-
describe('Default scope preferences:', () => {
|
|
69
|
-
beforeEach(() => {
|
|
70
|
-
configuration = new configuration_1.Configuration(defaultConfiguration, new configuration_1.ConfigurationModel({}, []), undefined, undefined);
|
|
71
|
-
inspect = configuration.inspect(propertyName, workspace, undefined);
|
|
72
|
-
});
|
|
73
|
-
it('should have correct value of \'default\' property', () => {
|
|
74
|
-
expect(inspect).to.have.property('default', preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
|
|
75
|
-
expect(inspect.default).to.equal(preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
|
|
76
|
-
});
|
|
77
|
-
it('should have correct value of \'value\' property', () => {
|
|
78
|
-
expect(inspect).to.have.property('value', preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
|
|
79
|
-
expect(inspect.value).to.equal(preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
describe('User scope preferences:', () => {
|
|
83
|
-
beforeEach(() => {
|
|
84
|
-
configuration = new configuration_1.Configuration(defaultConfiguration, userConfiguration, undefined, undefined);
|
|
85
|
-
inspect = configuration.inspect(propertyName, workspace, undefined);
|
|
86
|
-
});
|
|
87
|
-
it('should have correct value of \'default\' property', () => {
|
|
88
|
-
expect(inspect).to.have.property('default', preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
|
|
89
|
-
expect(inspect.default).to.equal(preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
|
|
90
|
-
});
|
|
91
|
-
it('should have correct value of \'user\' property', () => {
|
|
92
|
-
expect(inspect).to.have.property('user', preferences[preference_scope_1.PreferenceScope.User][propertyName]);
|
|
93
|
-
expect(inspect.user).to.equal(preferences[preference_scope_1.PreferenceScope.User][propertyName]);
|
|
94
|
-
});
|
|
95
|
-
it('should have correct value of \'value\' property', () => {
|
|
96
|
-
expect(inspect).to.have.property('value', preferences[preference_scope_1.PreferenceScope.User][propertyName]);
|
|
97
|
-
expect(inspect.value).to.equal(preferences[preference_scope_1.PreferenceScope.User][propertyName]);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
describe('Workspace scope preferences:', () => {
|
|
101
|
-
beforeEach(() => {
|
|
102
|
-
configuration = new configuration_1.Configuration(defaultConfiguration, userConfiguration, workspaceConfiguration, undefined);
|
|
103
|
-
inspect = configuration.inspect(propertyName, workspace, undefined);
|
|
104
|
-
});
|
|
105
|
-
it('should have correct value of \'default\' property', () => {
|
|
106
|
-
expect(inspect).to.have.property('default', preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
|
|
107
|
-
expect(inspect.default).to.equal(preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
|
|
108
|
-
});
|
|
109
|
-
it('should have correct value of \'user\' property', () => {
|
|
110
|
-
expect(inspect).to.have.property('user', preferences[preference_scope_1.PreferenceScope.User][propertyName]);
|
|
111
|
-
expect(inspect.user).to.equal(preferences[preference_scope_1.PreferenceScope.User][propertyName]);
|
|
112
|
-
});
|
|
113
|
-
it('should have correct value of \'workspace\' property', () => {
|
|
114
|
-
expect(inspect).to.have.property('workspace', preferences[preference_scope_1.PreferenceScope.Workspace][propertyName]);
|
|
115
|
-
expect(inspect.workspace).to.equal(preferences[preference_scope_1.PreferenceScope.Workspace][propertyName]);
|
|
116
|
-
});
|
|
117
|
-
it('should have correct value of \'value\' property', () => {
|
|
118
|
-
expect(inspect).to.have.property('value', preferences[preference_scope_1.PreferenceScope.Workspace][propertyName]);
|
|
119
|
-
expect(inspect.value).to.equal(preferences[preference_scope_1.PreferenceScope.Workspace][propertyName]);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
describe('Folder scope preferences:', () => {
|
|
123
|
-
const project = projects[0];
|
|
124
|
-
beforeEach(() => {
|
|
125
|
-
configuration = new configuration_1.Configuration(defaultConfiguration, userConfiguration, workspaceConfiguration, folderConfigurations);
|
|
126
|
-
const resource = vscode_uri_1.URI.revive({ path: project, scheme: '', authority: '', query: '', fragment: '' });
|
|
127
|
-
inspect = configuration.inspect(propertyName, workspace, resource);
|
|
128
|
-
});
|
|
129
|
-
it('should have correct value of \'default\' property', () => {
|
|
130
|
-
expect(inspect).to.have.property('default', preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
|
|
131
|
-
expect(inspect.default).to.equal(preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
|
|
132
|
-
});
|
|
133
|
-
it('should have correct value of \'user\' property', () => {
|
|
134
|
-
expect(inspect).to.have.property('user', preferences[preference_scope_1.PreferenceScope.User][propertyName]);
|
|
135
|
-
expect(inspect.user).to.equal(preferences[preference_scope_1.PreferenceScope.User][propertyName]);
|
|
136
|
-
});
|
|
137
|
-
it('should have correct value of \'workspace\' property', () => {
|
|
138
|
-
expect(inspect).to.have.property('workspace', preferences[preference_scope_1.PreferenceScope.Workspace][propertyName]);
|
|
139
|
-
expect(inspect.workspace).to.equal(preferences[preference_scope_1.PreferenceScope.Workspace][propertyName]);
|
|
140
|
-
});
|
|
141
|
-
it('should have correct value of \'workspaceFolder\' property', () => {
|
|
142
|
-
expect(inspect).to.have.property('workspaceFolder', preferences[preference_scope_1.PreferenceScope.Folder][project][propertyName]);
|
|
143
|
-
expect(inspect.workspaceFolder).to.equal(preferences[preference_scope_1.PreferenceScope.Folder][project][propertyName]);
|
|
144
|
-
});
|
|
145
|
-
it('should have correct value of \'value\' property', () => {
|
|
146
|
-
expect(inspect).to.have.property('value', preferences[preference_scope_1.PreferenceScope.Folder][project][propertyName]);
|
|
147
|
-
expect(inspect.value).to.equal(preferences[preference_scope_1.PreferenceScope.Folder][project][propertyName]);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
describe('ConfigurationModel', () => {
|
|
151
|
-
it('check merge', () => {
|
|
152
|
-
defaultConfiguration = new configuration_1.ConfigurationModel(preferences[preference_scope_1.PreferenceScope.Default], Object.keys(preferences[preference_scope_1.PreferenceScope.Default]));
|
|
153
|
-
userConfiguration = new configuration_1.ConfigurationModel(preferences[preference_scope_1.PreferenceScope.User], Object.keys(preferences[preference_scope_1.PreferenceScope.User]));
|
|
154
|
-
workspaceConfiguration = new configuration_1.ConfigurationModel(preferences[preference_scope_1.PreferenceScope.Workspace], Object.keys(preferences[preference_scope_1.PreferenceScope.Workspace]));
|
|
155
|
-
const mergedConfiguration = new configuration_1.ConfigurationModel().merge(defaultConfiguration, userConfiguration, workspaceConfiguration);
|
|
156
|
-
expect(mergedConfiguration.getValue('tabSize')).to.equal(4);
|
|
157
|
-
});
|
|
158
|
-
it('Prototype pollution check', () => {
|
|
159
|
-
const payload = JSON.parse('{"__proto__":{"injectedConfigurationPrototype": true}}');
|
|
160
|
-
const configurationModel = new configuration_1.ConfigurationModel();
|
|
161
|
-
configurationModel.merge(new configuration_1.ConfigurationModel(payload));
|
|
162
|
-
const prototypeObject = Object.prototype;
|
|
163
|
-
expect(prototypeObject.injectedConfigurationPrototype).to.be.an('undefined');
|
|
164
|
-
const rawObject = {};
|
|
165
|
-
expect(rawObject.injectedConfigurationPrototype).to.be.an('undefined');
|
|
166
|
-
});
|
|
167
|
-
it('Prototype constructor pollution check', () => {
|
|
168
|
-
const payload = JSON.parse('{"constructor": {"prototype": {"injectedConfigurationConstructorPrototype": true}}}');
|
|
169
|
-
const configurationModel = new configuration_1.ConfigurationModel();
|
|
170
|
-
configurationModel.merge(new configuration_1.ConfigurationModel(payload));
|
|
171
|
-
const prototypeObject = Object.prototype;
|
|
172
|
-
expect(prototypeObject.injectedConfigurationConstructorPrototype).to.be.an('undefined');
|
|
173
|
-
const rawObject = {};
|
|
174
|
-
expect(rawObject.injectedConfigurationConstructorPrototype).to.be.an('undefined');
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
//# sourceMappingURL=configuration.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.spec.js","sourceRoot":"","sources":["../../../src/plugin/preferences/configuration.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;AAEhF,uDAAuD;AACvD,6BAA6B;AAC7B,mDAAoE;AAEpE,0FAAsF;AAEtF,8DAAoD;AAEpD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;AAS3B,IAAI,OAAwB,CAAC;AAE7B,MAAM,QAAQ,GAAG,CAAC,8BAA8B,EAAE,8BAA8B,CAAC,CAAC;AAElF,MAAM,YAAY,GAAG,SAAS,CAAC;AAC/B,MAAM,WAAW,GAAmB;I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8BAA8B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;QAC3E,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;YAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,qFAAqF,CAAC,CAAC;YAClH,MAAM,kBAAkB,GAAG,IAAI,kCAAkB,EAAE,CAAC;YACpD,kBAAkB,CAAC,KAAK,CAAC,IAAI,kCAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;YAC1D,MAAM,eAAe,GAAG,MAAM,CAAC,SAAgB,CAAC;YAChD,MAAM,CAAC,eAAe,CAAC,yCAAyC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;YACxF,MAAM,SAAS,GAAG,EAAS,CAAC;YAC5B,MAAM,CAAC,SAAS,CAAC,yCAAyC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;QACtF,CAAC,CAAC,CAAC;IAEP,CAAC,CAAC,CAAC;AAEP,CAAC,CAAC,CAAC"}
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
18
|
-
import * as chai from 'chai';
|
|
19
|
-
import { Configuration, ConfigurationModel } from './configuration';
|
|
20
|
-
import { PreferenceData } from '../../common';
|
|
21
|
-
import { PreferenceScope } from '@theia/core/lib/common/preferences/preference-scope';
|
|
22
|
-
import { WorkspaceExtImpl } from '../workspace';
|
|
23
|
-
import { URI } from '@theia/core/shared/vscode-uri';
|
|
24
|
-
|
|
25
|
-
const expect = chai.expect;
|
|
26
|
-
|
|
27
|
-
interface Inspect<C> {
|
|
28
|
-
default: C;
|
|
29
|
-
user: C;
|
|
30
|
-
workspace?: C;
|
|
31
|
-
workspaceFolder?: C;
|
|
32
|
-
value: C;
|
|
33
|
-
}
|
|
34
|
-
let inspect: Inspect<number>;
|
|
35
|
-
|
|
36
|
-
const projects = ['/projects/workspace/project1', '/projects/workspace/project2'];
|
|
37
|
-
|
|
38
|
-
const propertyName = 'tabSize';
|
|
39
|
-
const preferences: PreferenceData = {
|
|
40
|
-
[PreferenceScope.Default]: {
|
|
41
|
-
[propertyName]: 6,
|
|
42
|
-
},
|
|
43
|
-
[PreferenceScope.User]: {
|
|
44
|
-
[propertyName]: 5
|
|
45
|
-
},
|
|
46
|
-
[PreferenceScope.Workspace]: {
|
|
47
|
-
[propertyName]: 4
|
|
48
|
-
},
|
|
49
|
-
[PreferenceScope.Folder]: {
|
|
50
|
-
[projects[0]]: {
|
|
51
|
-
[propertyName]: 3
|
|
52
|
-
},
|
|
53
|
-
[projects[1]]: {
|
|
54
|
-
[propertyName]: 2
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const workspace: WorkspaceExtImpl = {} as WorkspaceExtImpl;
|
|
60
|
-
let configuration: Configuration;
|
|
61
|
-
let defaultConfiguration: ConfigurationModel;
|
|
62
|
-
let userConfiguration: ConfigurationModel;
|
|
63
|
-
let workspaceConfiguration: ConfigurationModel;
|
|
64
|
-
let folderConfigurations: { [key: string]: ConfigurationModel };
|
|
65
|
-
before(() => {
|
|
66
|
-
workspace.getWorkspaceFolder = (uri => {
|
|
67
|
-
const name = uri.toString().replace(/[^\/]+$/, '$1');
|
|
68
|
-
const index = projects.indexOf(uri.toString());
|
|
69
|
-
return { uri, name, index };
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
defaultConfiguration = new ConfigurationModel(
|
|
73
|
-
preferences[PreferenceScope.Default],
|
|
74
|
-
Object.keys(preferences[PreferenceScope.Default])
|
|
75
|
-
);
|
|
76
|
-
userConfiguration = new ConfigurationModel(
|
|
77
|
-
preferences[PreferenceScope.User],
|
|
78
|
-
Object.keys(preferences[PreferenceScope.User])
|
|
79
|
-
);
|
|
80
|
-
workspaceConfiguration = new ConfigurationModel(
|
|
81
|
-
preferences[PreferenceScope.Workspace],
|
|
82
|
-
Object.keys(preferences[PreferenceScope.Workspace])
|
|
83
|
-
);
|
|
84
|
-
folderConfigurations = projects.reduce((configurations: { [key: string]: ConfigurationModel }, project: string) => {
|
|
85
|
-
const folderPrefs = preferences[PreferenceScope.Folder][project];
|
|
86
|
-
configurations[project] = new ConfigurationModel(folderPrefs, Object.keys(folderPrefs));
|
|
87
|
-
return configurations;
|
|
88
|
-
}, {});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
describe('Configuration:', () => {
|
|
92
|
-
|
|
93
|
-
describe('Default scope preferences:', () => {
|
|
94
|
-
|
|
95
|
-
beforeEach(() => {
|
|
96
|
-
configuration = new Configuration(
|
|
97
|
-
defaultConfiguration, new ConfigurationModel({}, []), undefined, undefined
|
|
98
|
-
);
|
|
99
|
-
inspect = configuration.inspect(propertyName, workspace, undefined);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('should have correct value of \'default\' property', () => {
|
|
103
|
-
expect(inspect).to.have.property(
|
|
104
|
-
'default',
|
|
105
|
-
preferences[PreferenceScope.Default][propertyName]
|
|
106
|
-
);
|
|
107
|
-
expect(inspect.default).to.equal(preferences[PreferenceScope.Default][propertyName]);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('should have correct value of \'value\' property', () => {
|
|
111
|
-
expect(inspect).to.have.property(
|
|
112
|
-
'value',
|
|
113
|
-
preferences[PreferenceScope.Default][propertyName]
|
|
114
|
-
);
|
|
115
|
-
expect(inspect.value).to.equal(preferences[PreferenceScope.Default][propertyName]);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
describe('User scope preferences:', () => {
|
|
121
|
-
|
|
122
|
-
beforeEach(() => {
|
|
123
|
-
configuration = new Configuration(
|
|
124
|
-
defaultConfiguration, userConfiguration, undefined, undefined
|
|
125
|
-
);
|
|
126
|
-
inspect = configuration.inspect(propertyName, workspace, undefined);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('should have correct value of \'default\' property', () => {
|
|
130
|
-
expect(inspect).to.have.property(
|
|
131
|
-
'default',
|
|
132
|
-
preferences[PreferenceScope.Default][propertyName]
|
|
133
|
-
);
|
|
134
|
-
expect(inspect.default).to.equal(preferences[PreferenceScope.Default][propertyName]);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('should have correct value of \'user\' property', () => {
|
|
138
|
-
expect(inspect).to.have.property(
|
|
139
|
-
'user',
|
|
140
|
-
preferences[PreferenceScope.User][propertyName]
|
|
141
|
-
);
|
|
142
|
-
expect(inspect.user).to.equal(preferences[PreferenceScope.User][propertyName]);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('should have correct value of \'value\' property', () => {
|
|
146
|
-
expect(inspect).to.have.property(
|
|
147
|
-
'value',
|
|
148
|
-
preferences[PreferenceScope.User][propertyName]
|
|
149
|
-
);
|
|
150
|
-
expect(inspect.value).to.equal(preferences[PreferenceScope.User][propertyName]);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
describe('Workspace scope preferences:', () => {
|
|
156
|
-
|
|
157
|
-
beforeEach(() => {
|
|
158
|
-
configuration = new Configuration(
|
|
159
|
-
defaultConfiguration, userConfiguration, workspaceConfiguration, undefined
|
|
160
|
-
);
|
|
161
|
-
inspect = configuration.inspect(propertyName, workspace, undefined);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('should have correct value of \'default\' property', () => {
|
|
165
|
-
expect(inspect).to.have.property(
|
|
166
|
-
'default',
|
|
167
|
-
preferences[PreferenceScope.Default][propertyName]
|
|
168
|
-
);
|
|
169
|
-
expect(inspect.default).to.equal(preferences[PreferenceScope.Default][propertyName]);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it('should have correct value of \'user\' property', () => {
|
|
173
|
-
expect(inspect).to.have.property(
|
|
174
|
-
'user',
|
|
175
|
-
preferences[PreferenceScope.User][propertyName]
|
|
176
|
-
);
|
|
177
|
-
expect(inspect.user).to.equal(preferences[PreferenceScope.User][propertyName]);
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it('should have correct value of \'workspace\' property', () => {
|
|
181
|
-
expect(inspect).to.have.property(
|
|
182
|
-
'workspace',
|
|
183
|
-
preferences[PreferenceScope.Workspace][propertyName]
|
|
184
|
-
);
|
|
185
|
-
expect(inspect.workspace).to.equal(preferences[PreferenceScope.Workspace][propertyName]);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('should have correct value of \'value\' property', () => {
|
|
189
|
-
expect(inspect).to.have.property(
|
|
190
|
-
'value',
|
|
191
|
-
preferences[PreferenceScope.Workspace][propertyName]
|
|
192
|
-
);
|
|
193
|
-
expect(inspect.value).to.equal(preferences[PreferenceScope.Workspace][propertyName]);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
describe('Folder scope preferences:', () => {
|
|
199
|
-
const project = projects[0];
|
|
200
|
-
|
|
201
|
-
beforeEach(() => {
|
|
202
|
-
configuration = new Configuration(
|
|
203
|
-
defaultConfiguration, userConfiguration, workspaceConfiguration, folderConfigurations
|
|
204
|
-
);
|
|
205
|
-
const resource = URI.revive({ path: project, scheme: '', authority: '', query: '', fragment: '' });
|
|
206
|
-
inspect = configuration.inspect(propertyName, workspace, resource);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it('should have correct value of \'default\' property', () => {
|
|
210
|
-
expect(inspect).to.have.property(
|
|
211
|
-
'default',
|
|
212
|
-
preferences[PreferenceScope.Default][propertyName]
|
|
213
|
-
);
|
|
214
|
-
expect(inspect.default).to.equal(preferences[PreferenceScope.Default][propertyName]);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it('should have correct value of \'user\' property', () => {
|
|
218
|
-
expect(inspect).to.have.property(
|
|
219
|
-
'user',
|
|
220
|
-
preferences[PreferenceScope.User][propertyName]
|
|
221
|
-
);
|
|
222
|
-
expect(inspect.user).to.equal(preferences[PreferenceScope.User][propertyName]);
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
it('should have correct value of \'workspace\' property', () => {
|
|
226
|
-
expect(inspect).to.have.property(
|
|
227
|
-
'workspace',
|
|
228
|
-
preferences[PreferenceScope.Workspace][propertyName]
|
|
229
|
-
);
|
|
230
|
-
expect(inspect.workspace).to.equal(preferences[PreferenceScope.Workspace][propertyName]);
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
it('should have correct value of \'workspaceFolder\' property', () => {
|
|
234
|
-
expect(inspect).to.have.property(
|
|
235
|
-
'workspaceFolder',
|
|
236
|
-
preferences[PreferenceScope.Folder][project][propertyName]
|
|
237
|
-
);
|
|
238
|
-
expect(inspect.workspaceFolder).to.equal(preferences[PreferenceScope.Folder][project][propertyName]);
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it('should have correct value of \'value\' property', () => {
|
|
242
|
-
expect(inspect).to.have.property(
|
|
243
|
-
'value',
|
|
244
|
-
preferences[PreferenceScope.Folder][project][propertyName]
|
|
245
|
-
);
|
|
246
|
-
expect(inspect.value).to.equal(preferences[PreferenceScope.Folder][project][propertyName]);
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
describe('ConfigurationModel', () => {
|
|
252
|
-
|
|
253
|
-
it('check merge', () => {
|
|
254
|
-
defaultConfiguration = new ConfigurationModel(
|
|
255
|
-
preferences[PreferenceScope.Default],
|
|
256
|
-
Object.keys(preferences[PreferenceScope.Default])
|
|
257
|
-
);
|
|
258
|
-
userConfiguration = new ConfigurationModel(
|
|
259
|
-
preferences[PreferenceScope.User],
|
|
260
|
-
Object.keys(preferences[PreferenceScope.User])
|
|
261
|
-
);
|
|
262
|
-
workspaceConfiguration = new ConfigurationModel(
|
|
263
|
-
preferences[PreferenceScope.Workspace],
|
|
264
|
-
Object.keys(preferences[PreferenceScope.Workspace])
|
|
265
|
-
);
|
|
266
|
-
const mergedConfiguration = new ConfigurationModel().merge(defaultConfiguration, userConfiguration, workspaceConfiguration);
|
|
267
|
-
expect(mergedConfiguration.getValue('tabSize')).to.equal(4);
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
it('Prototype pollution check', () => {
|
|
271
|
-
const payload = JSON.parse('{"__proto__":{"injectedConfigurationPrototype": true}}');
|
|
272
|
-
const configurationModel = new ConfigurationModel();
|
|
273
|
-
configurationModel.merge(new ConfigurationModel(payload));
|
|
274
|
-
const prototypeObject = Object.prototype as any;
|
|
275
|
-
expect(prototypeObject.injectedConfigurationPrototype).to.be.an('undefined');
|
|
276
|
-
const rawObject = {} as any;
|
|
277
|
-
expect(rawObject.injectedConfigurationPrototype).to.be.an('undefined');
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
it('Prototype constructor pollution check', () => {
|
|
281
|
-
const payload = JSON.parse('{"constructor": {"prototype": {"injectedConfigurationConstructorPrototype": true}}}');
|
|
282
|
-
const configurationModel = new ConfigurationModel();
|
|
283
|
-
configurationModel.merge(new ConfigurationModel(payload));
|
|
284
|
-
const prototypeObject = Object.prototype as any;
|
|
285
|
-
expect(prototypeObject.injectedConfigurationConstructorPrototype).to.be.an('undefined');
|
|
286
|
-
const rawObject = {} as any;
|
|
287
|
-
expect(rawObject.injectedConfigurationConstructorPrototype).to.be.an('undefined');
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
});
|