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) 2018-2021 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.
@@ -139,30 +139,28 @@ describe('DataProvider', () => {
};
dataProvider.backendQueriesLimit = 2;
spyOn(Client.prototype as any, 'multiSearch').and.callFake(
(request_: SCMultiSearchRequest) => ({
then: (callback: any) => {
let i = 0;
for (const key in request_) {
if (request_.hasOwnProperty(key)) {
i++;
spyOn(Client.prototype as any, 'multiSearch').and.callFake((request_: SCMultiSearchRequest) => ({
then: (callback: any) => {
let i = 0;
for (const key in request_) {
if (request_.hasOwnProperty(key)) {
i++;
expect(requestCheck[key]).not.toBeNull();
expect(requestCheck[key]).toEqual(request_[key]);
expect(requestCheck[key]).not.toBeNull();
expect(requestCheck[key]).toEqual(request_[key]);
// @ts-expect-error is not null
// eslint-disable-next-line unicorn/no-null
requestCheck[key] = null;
// @ts-expect-error is a string for test purposes
request_[key] = request_[key].toUpperCase();
}
// @ts-expect-error is not null
// eslint-disable-next-line unicorn/no-null
requestCheck[key] = null;
// @ts-expect-error is a string for test purposes
request_[key] = request_[key].toUpperCase();
}
expect(i).toBeLessThanOrEqual(dataProvider.backendQueriesLimit);
}
expect(i).toBeLessThanOrEqual(dataProvider.backendQueriesLimit);
return callback(request_);
},
}),
);
return callback(request_);
},
}));
const response = await dataProvider.multiSearch(request);
// @ts-expect-error same type
@@ -171,12 +169,10 @@ describe('DataProvider', () => {
it('should put an data item into the local database (storage)', async () => {
let providedThing: SCSaveableThing;
spyOn(storageProvider, 'put' as any).and.callFake(
(_id: any, thing: any) => {
providedThing = thing;
providedThing.origin.created = sampleSavable.origin.created;
},
);
spyOn(storageProvider, 'put' as any).and.callFake((_id: any, thing: any) => {
providedThing = thing;
providedThing.origin.created = sampleSavable.origin.created;
});
expect(storageProvider.put).not.toHaveBeenCalled();
expect(providedThing!).not.toBeDefined();
@@ -188,20 +184,13 @@ describe('DataProvider', () => {
});
it('should correctly set and get single data item from the local database (storage)', async () => {
spyOn(storageProvider, 'get').and.returnValue(
(async () => sampleSavable)(),
);
spyOn(storageProvider, 'get').and.returnValue((async () => sampleSavable)());
expect(storageProvider.get).not.toHaveBeenCalled();
const providedThing = await dataProvider.get(
sampleThing.uid,
DataScope.Local,
);
const providedThing = await dataProvider.get(sampleThing.uid, DataScope.Local);
expect(storageProvider.get).toHaveBeenCalledWith(
dataProvider.getDataKey(sampleThing.uid),
);
expect(storageProvider.get).toHaveBeenCalledWith(dataProvider.getDataKey(sampleThing.uid));
expect(providedThing).toEqual(sampleSavable);
});
@@ -217,9 +206,7 @@ describe('DataProvider', () => {
const result = await dataProvider.getAll();
expect([...result.keys()].sort()).toEqual([...fakeStorage.keys()].sort());
expect([...result.values()].sort()).toEqual(
[...fakeStorage.values()].sort(),
);
expect([...result.values()].sort()).toEqual([...fakeStorage.values()].sort());
});
it('should provide single data from the backend', async () => {
@@ -233,10 +220,7 @@ describe('DataProvider', () => {
expect(Client.prototype.getThing).not.toHaveBeenCalled();
const providedThing = await dataProvider.get(
sampleThing.uid,
DataScope.Remote,
);
const providedThing = await dataProvider.get(sampleThing.uid, DataScope.Remote);
expect(Client.prototype.getThing).toHaveBeenCalledWith(sampleThing.uid);
expect(providedThing).toBe(sampleThing);
@@ -268,9 +252,7 @@ describe('DataProvider', () => {
await dataProvider.delete(sampleThing.uid);
expect(storageProvider.delete).toHaveBeenCalledWith(
dataProvider.getDataKey(sampleThing.uid),
);
expect(storageProvider.delete).toHaveBeenCalledWith(dataProvider.getDataKey(sampleThing.uid));
});
it('should properly delete all the data items from the local database (storage)', async () => {