mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-04 04:22:50 +00:00
committed by
Jovan Krunić
parent
301f872c06
commit
161da630ea
@@ -153,6 +153,13 @@ describe('ConfigProvider', () => {
|
|||||||
await configProvider.init();
|
await configProvider.init();
|
||||||
expect(await configProvider.getValue('name')).toEqual(sampleIndexResponse.app.name);
|
expect(await configProvider.getValue('name')).toEqual(sampleIndexResponse.app.name);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return app configuration value if only saved config is available and fetch fails', async () => {
|
||||||
|
storageProviderSpy.has.and.returnValue(true);
|
||||||
|
storageProviderSpy.get.and.returnValue(sampleIndexResponse);
|
||||||
|
spyOn(configProvider.client, 'handshake').and.throwError('');
|
||||||
|
expect(await configProvider.getValue('name')).toEqual(sampleIndexResponse.app.name);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const sampleIndexResponse: SCIndexResponse = {
|
const sampleIndexResponse: SCIndexResponse = {
|
||||||
|
|||||||
@@ -66,7 +66,14 @@ export class ConfigProvider {
|
|||||||
*/
|
*/
|
||||||
public async getValue(attribute: keyof SCAppConfiguration) {
|
public async getValue(attribute: keyof SCAppConfiguration) {
|
||||||
if (!this.initialised) {
|
if (!this.initialised) {
|
||||||
await this.init();
|
try {
|
||||||
|
await this.init();
|
||||||
|
} catch (error) {
|
||||||
|
// don't throw ConfigFetchError if saved config is available
|
||||||
|
if (!(error.name === 'ConfigFetchError' && this.initialised)) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (typeof this.config.app[attribute] !== 'undefined') {
|
if (typeof this.config.app[attribute] !== 'undefined') {
|
||||||
return this.config.app[attribute];
|
return this.config.app[attribute];
|
||||||
|
|||||||
Reference in New Issue
Block a user