feat: separate prettier from eslint

This commit is contained in:
Rainer Killinger
2023-01-11 13:25:18 +01:00
committed by Thea Schöbl
parent 939fb6ef0f
commit a88d000ccd
381 changed files with 17952 additions and 38411 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 StApps
* Copyright (C) 2023 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
@@ -31,15 +31,8 @@ describe('ConfigProvider', () => {
let ngxLogger: jasmine.SpyObj<NGXLogger>;
beforeEach(() => {
storageProviderSpy = jasmine.createSpyObj('StorageProvider', [
'init',
'get',
'has',
'put',
]);
const webHttpClientMethodSpy = jasmine.createSpyObj('StAppsWebHttpClient', [
'request',
]);
storageProviderSpy = jasmine.createSpyObj('StorageProvider', ['init', 'get', 'has', 'put']);
const webHttpClientMethodSpy = jasmine.createSpyObj('StAppsWebHttpClient', ['request']);
ngxLogger = jasmine.createSpyObj('NGXLogger', ['log', 'error', 'warn']);
TestBed.configureTestingModule({
@@ -65,9 +58,7 @@ describe('ConfigProvider', () => {
});
it('should fetch app configuration', async () => {
spyOn(configProvider.client, 'handshake').and.returnValue(
Promise.resolve(sampleIndexResponse),
);
spyOn(configProvider.client, 'handshake').and.returnValue(Promise.resolve(sampleIndexResponse));
const result = await configProvider.fetch();
expect(result).toEqual(sampleIndexResponse);
});
@@ -86,9 +77,7 @@ describe('ConfigProvider', () => {
it('should init from remote and saved config not available', async () => {
storageProviderSpy.has.and.returnValue(Promise.resolve(false));
spyOn(configProvider.client, 'handshake').and.returnValue(
Promise.resolve(sampleIndexResponse),
);
spyOn(configProvider.client, 'handshake').and.returnValue(Promise.resolve(sampleIndexResponse));
try {
await configProvider.init();
} catch (error) {
@@ -97,9 +86,7 @@ describe('ConfigProvider', () => {
expect(storageProviderSpy.has).toHaveBeenCalled();
expect(storageProviderSpy.get).toHaveBeenCalledTimes(0);
expect(configProvider.client.handshake).toHaveBeenCalled();
expect(await configProvider.getValue('name')).toEqual(
sampleIndexResponse.app.name,
);
expect(await configProvider.getValue('name')).toEqual(sampleIndexResponse.app.name);
});
it('should throw error on failed initialisation', async () => {
@@ -120,16 +107,11 @@ describe('ConfigProvider', () => {
const wrongConfig = JSON.parse(JSON.stringify(sampleIndexResponse));
wrongConfig.backend.SCVersion = '0.1.0';
storageProviderSpy.get.and.returnValue(wrongConfig);
spyOn(configProvider.client, 'handshake').and.returnValue(
Promise.resolve(sampleIndexResponse),
);
spyOn(configProvider.client, 'handshake').and.returnValue(Promise.resolve(sampleIndexResponse));
await configProvider.init();
expect(ngxLogger.warn).toHaveBeenCalledWith(
new WrongConfigVersionInStorage(
configProvider.scVersion,
wrongConfig.backend.SCVersion,
),
new WrongConfigVersionInStorage(configProvider.scVersion, wrongConfig.backend.SCVersion),
);
});
@@ -147,10 +129,7 @@ describe('ConfigProvider', () => {
it('should save app configuration', async () => {
await configProvider.save(sampleIndexResponse);
expect(storageProviderSpy.put).toHaveBeenCalledWith(
STORAGE_KEY_CONFIG,
sampleIndexResponse,
);
expect(storageProviderSpy.put).toHaveBeenCalledWith(STORAGE_KEY_CONFIG, sampleIndexResponse);
});
it('should set app configuration', async () => {
@@ -160,28 +139,18 @@ describe('ConfigProvider', () => {
it('should return app configuration value', async () => {
storageProviderSpy.has.and.returnValue(Promise.resolve(true));
storageProviderSpy.get.and.returnValue(
Promise.resolve(sampleIndexResponse),
);
spyOn(configProvider.client, 'handshake').and.returnValue(
Promise.resolve(sampleIndexResponse),
);
storageProviderSpy.get.and.returnValue(Promise.resolve(sampleIndexResponse));
spyOn(configProvider.client, 'handshake').and.returnValue(Promise.resolve(sampleIndexResponse));
await configProvider.init();
expect(await configProvider.getValue('name')).toEqual(
sampleIndexResponse.app.name,
);
expect(await configProvider.getValue('name')).toEqual(sampleIndexResponse.app.name);
});
it('should init from storage when remote fails', async () => {
storageProviderSpy.has.and.returnValue(Promise.resolve(true));
storageProviderSpy.get.and.returnValue(
Promise.resolve(sampleIndexResponse),
);
storageProviderSpy.get.and.returnValue(Promise.resolve(sampleIndexResponse));
spyOn(configProvider.client, 'handshake').and.throwError('');
await configProvider.init();
expect(configProvider.getValue('name')).toEqual(
sampleIndexResponse.app.name,
);
expect(configProvider.getValue('name')).toEqual(sampleIndexResponse.app.name);
});
});

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019, 2020 StApps
* Copyright (C) 2022 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
@@ -74,11 +74,7 @@ export class ConfigProvider {
swHttpClient: StAppsWebHttpClient,
private readonly logger: NGXLogger,
) {
this.client = new Client(
swHttpClient,
environment.backend_url,
environment.backend_version,
);
this.client = new Client(swHttpClient, environment.backend_url, environment.backend_version);
}
/**
@@ -131,10 +127,7 @@ export class ConfigProvider {
this.firstSession = false;
this.logger.log(`initialised configuration from storage`);
if (this.config.backend.SCVersion !== this.scVersion) {
loadError = new WrongConfigVersionInStorage(
this.scVersion,
this.config.backend.SCVersion,
);
loadError = new WrongConfigVersionInStorage(this.scVersion, this.config.backend.SCVersion);
}
} catch (error) {
loadError = error;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2022 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
@@ -38,10 +38,7 @@ export class ConfigInitError extends AppError {
*/
export class ConfigValueNotAvailable extends AppError {
constructor(valueKey: string) {
super(
'ConfigValueNotAvailable',
`No attribute "${valueKey}" in config available!`,
);
super('ConfigValueNotAvailable', `No attribute "${valueKey}" in config available!`);
}
}