-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
application-package: refine config typings
Rework how the different application configurations are defined to allow partial setting when calling configuration providers. Use default values when setting a partial configuration through the configuration providers.
- Loading branch information
1 parent
f9c0311
commit bcb8fbb
Showing
6 changed files
with
221 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/core/src/browser/frontend-application-config-provider.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2021 Ericsson and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
import { enableJSDOM } from '../browser/test/jsdom'; | ||
let disableJSDOM = enableJSDOM(); | ||
|
||
import { FrontendApplicationConfig } from '@theia/application-package/lib/'; | ||
import { expect } from 'chai'; | ||
import { FrontendApplicationConfigProvider } from './frontend-application-config-provider'; | ||
|
||
disableJSDOM(); | ||
|
||
const { DEFAULT } = FrontendApplicationConfig; | ||
|
||
describe('FrontendApplicationConfigProvider', function (): void { | ||
|
||
before(() => disableJSDOM = enableJSDOM()); | ||
after(() => disableJSDOM()); | ||
|
||
it('should use defaults when calling `set`', function (): void { | ||
FrontendApplicationConfigProvider.set({ | ||
applicationName: DEFAULT.applicationName + ' Something Else', | ||
electron: { | ||
disallowReloadKeybinding: !DEFAULT.electron.disallowReloadKeybinding | ||
} | ||
}); | ||
const config = FrontendApplicationConfigProvider.get(); | ||
// custom values | ||
expect(config.applicationName).not.equal(DEFAULT.applicationName); | ||
expect(config.electron.disallowReloadKeybinding).not.equal(DEFAULT.electron.disallowReloadKeybinding); | ||
// defaults | ||
expect(config.defaultIconTheme).equal(DEFAULT.defaultIconTheme); | ||
expect(config.defaultTheme).equal(DEFAULT.defaultTheme); | ||
expect(config.electron.windowOptions).deep.equal(DEFAULT.electron.windowOptions); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/core/src/node/backend-application-config-provider.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2021 Ericsson and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
import { BackendApplicationConfig } from '@theia/application-package/lib/'; | ||
import { expect } from 'chai'; | ||
import { BackendApplicationConfigProvider } from './backend-application-config-provider'; | ||
|
||
const { DEFAULT } = BackendApplicationConfig; | ||
|
||
describe('BackendApplicationConfigProvider', function (): void { | ||
it('should use defaults when calling `set`', function (): void { | ||
BackendApplicationConfigProvider.set({}); | ||
const config = BackendApplicationConfigProvider.get(); | ||
expect(config.singleInstance).equal(DEFAULT.singleInstance); | ||
}); | ||
}); |
Oops, something went wrong.