mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-23 10:02:51 +00:00
test: inject instead of deprecated TestBed get
Additionally refactor tests and ts-ignore annotations.
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {SCAuthorizationProvider, SCBackendAggregationConfiguration, SCThingType} from '@openstapps/core';
|
import {SCAuthorizationProvider, SCBackendAggregationConfiguration, SCThingType} from '@openstapps/core';
|
||||||
|
import {Polygon} from 'geojson';
|
||||||
|
|
||||||
// provides sample aggregations to be used in tests or backendless development
|
// provides sample aggregations to be used in tests or backendless development
|
||||||
export const sampleAggregations: SCBackendAggregationConfiguration[] = [
|
export const sampleAggregations: SCBackendAggregationConfiguration[] = [
|
||||||
@@ -90,7 +91,7 @@ export const sampleAuthConfiguration: {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sampleDefaultPolygon = {
|
export const sampleDefaultPolygon: Polygon = {
|
||||||
"coordinates": [
|
"coordinates": [
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ describe('ConfigProvider', () => {
|
|||||||
let ngxLogger: jasmine.SpyObj<NGXLogger>;
|
let ngxLogger: jasmine.SpyObj<NGXLogger>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const storageProviderMethodSpy = jasmine.createSpyObj('StorageProvider', [
|
storageProviderSpy = jasmine.createSpyObj('StorageProvider', [
|
||||||
'init',
|
'init',
|
||||||
'get',
|
'get',
|
||||||
'has',
|
'has',
|
||||||
@@ -55,7 +55,7 @@ describe('ConfigProvider', () => {
|
|||||||
ConfigProvider,
|
ConfigProvider,
|
||||||
{
|
{
|
||||||
provide: StorageProvider,
|
provide: StorageProvider,
|
||||||
useValue: storageProviderMethodSpy,
|
useValue: storageProviderSpy,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: StAppsWebHttpClient,
|
provide: StAppsWebHttpClient,
|
||||||
@@ -68,8 +68,7 @@ describe('ConfigProvider', () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
configProvider = TestBed.get(ConfigProvider);
|
configProvider = TestBed.inject(ConfigProvider);
|
||||||
storageProviderSpy = TestBed.get(StorageProvider);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch app configuration', async () => {
|
it('should fetch app configuration', async () => {
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ describe('DataProvider', () => {
|
|||||||
imports: [DataModule],
|
imports: [DataModule],
|
||||||
providers: [DataProvider, StAppsWebHttpClient],
|
providers: [DataProvider, StAppsWebHttpClient],
|
||||||
});
|
});
|
||||||
dataFacetsProvider = TestBed.get(DataFacetsProvider);
|
dataFacetsProvider = TestBed.inject(DataFacetsProvider);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add buckets properly', () => {
|
it('should add buckets properly', () => {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-non-null-assertion,@typescript-eslint/ban-ts-comment,@typescript-eslint/no-explicit-any */
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2018-2021 StApps
|
* Copyright (C) 2018-2021 StApps
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
@@ -13,6 +12,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
/* eslint-disable @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-explicit-any */
|
||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
import {Client} from '@openstapps/api/lib/client';
|
import {Client} from '@openstapps/api/lib/client';
|
||||||
import {
|
import {
|
||||||
@@ -85,8 +85,8 @@ describe('DataProvider', () => {
|
|||||||
imports: [DataModule],
|
imports: [DataModule],
|
||||||
providers: [DataProvider, StAppsWebHttpClient],
|
providers: [DataProvider, StAppsWebHttpClient],
|
||||||
});
|
});
|
||||||
storageProvider = TestBed.get(StorageProvider);
|
storageProvider = TestBed.inject(StorageProvider);
|
||||||
dataProvider = TestBed.get(DataProvider);
|
dataProvider = TestBed.inject(DataProvider);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should generate data key', async () => {
|
it('should generate data key', async () => {
|
||||||
@@ -146,13 +146,14 @@ describe('DataProvider', () => {
|
|||||||
for (const key in request_) {
|
for (const key in request_) {
|
||||||
if (request_.hasOwnProperty(key)) {
|
if (request_.hasOwnProperty(key)) {
|
||||||
i++;
|
i++;
|
||||||
// @ts-ignore
|
|
||||||
expect(requestCheck[key]).not.toBeNull();
|
expect(requestCheck[key]).not.toBeNull();
|
||||||
expect(requestCheck[key]).toEqual(request_[key]);
|
expect(requestCheck[key]).toEqual(request_[key]);
|
||||||
// @ts-ignore
|
|
||||||
|
// @ts-expect-error is not null
|
||||||
// eslint-disable-next-line unicorn/no-null
|
// eslint-disable-next-line unicorn/no-null
|
||||||
requestCheck[key] = null;
|
requestCheck[key] = null;
|
||||||
// @ts-ignore
|
// @ts-expect-error is a string for test purposes
|
||||||
request_[key] = request_[key].toUpperCase();
|
request_[key] = request_[key].toUpperCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,7 +165,7 @@ describe('DataProvider', () => {
|
|||||||
);
|
);
|
||||||
const response = await dataProvider.multiSearch(request);
|
const response = await dataProvider.multiSearch(request);
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-expect-error same type
|
||||||
expect(response).toEqual(responseShould);
|
expect(response).toEqual(responseShould);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ describe('DataDetailComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
dataProvider = TestBed.get(DataProvider);
|
dataProvider = TestBed.inject(DataProvider);
|
||||||
translateService = TestBed.get(TranslateService);
|
translateService = TestBed.inject(TranslateService);
|
||||||
refresher = jasmine.createSpyObj('refresher', ['complete']);
|
refresher = jasmine.createSpyObj('refresher', ['complete']);
|
||||||
spyOn(dataProvider, 'get' as any).and.returnValue(
|
spyOn(dataProvider, 'get' as any).and.returnValue(
|
||||||
Promise.resolve(sampleThing),
|
Promise.resolve(sampleThing),
|
||||||
|
|||||||
@@ -109,10 +109,10 @@ describe('DaiaAvailabilityComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
dataProvider = TestBed.get(DaiaDataProvider);
|
dataProvider = TestBed.inject(DaiaDataProvider);
|
||||||
const workingDAIAurl = 'https://daia.hebis.de/DAIA2/UB_Frankfurt';
|
const workingDAIAurl = 'https://daia.hebis.de/DAIA2/UB_Frankfurt';
|
||||||
dataProvider.daiaServiceUrl = workingDAIAurl;
|
dataProvider.daiaServiceUrl = workingDAIAurl;
|
||||||
translateService = TestBed.get(TranslateService);
|
translateService = TestBed.inject(TranslateService);
|
||||||
refresher = jasmine.createSpyObj('refresher', ['complete']);
|
refresher = jasmine.createSpyObj('refresher', ['complete']);
|
||||||
spyOn(dataProvider, 'getAvailability' as any).and.returnValue(
|
spyOn(dataProvider, 'getAvailability' as any).and.returnValue(
|
||||||
Promise.resolve(sampleThing),
|
Promise.resolve(sampleThing),
|
||||||
|
|||||||
@@ -94,8 +94,8 @@ describe('HebisDetailComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
dataProvider = TestBed.get(HebisDataProvider);
|
dataProvider = TestBed.inject(HebisDataProvider);
|
||||||
translateService = TestBed.get(TranslateService);
|
translateService = TestBed.inject(TranslateService);
|
||||||
refresher = jasmine.createSpyObj('refresher', ['complete']);
|
refresher = jasmine.createSpyObj('refresher', ['complete']);
|
||||||
spyOn(dataProvider, 'get' as any).and.returnValue(
|
spyOn(dataProvider, 'get' as any).and.returnValue(
|
||||||
Promise.resolve(sampleThing),
|
Promise.resolve(sampleThing),
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ describe('MapProvider', () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-ignore
|
|
||||||
configProvider.getValue.and.returnValue(sampleDefaultPolygon);
|
configProvider.getValue.and.returnValue(sampleDefaultPolygon);
|
||||||
provider = TestBed.inject(MapProvider);
|
provider = TestBed.inject(MapProvider);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
/* eslint-disable @typescript-eslint/no-non-null-assertion,@typescript-eslint/ban-ts-comment */
|
/* eslint-disable @typescript-eslint/no-non-null-assertion, @typescript-eslint/ban-ts-comment */
|
||||||
import {
|
import {
|
||||||
APP_BASE_HREF,
|
APP_BASE_HREF,
|
||||||
CommonModule,
|
CommonModule,
|
||||||
@@ -103,7 +103,7 @@ describe('ContextMenuComponent', async () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const sort: HTMLElement =
|
const sort: HTMLElement =
|
||||||
fixture.debugElement.nativeElement.querySelector('.context-sort');
|
fixture.debugElement.nativeElement.querySelector('.context-sort');
|
||||||
// @ts-ignore
|
// @ts-expect-error not relevant for this case
|
||||||
const sortItem: HTMLElement = sort.querySelectorAll('.sort-item')[1];
|
const sortItem: HTMLElement = sort.querySelectorAll('.sort-item')[1];
|
||||||
sortItem!.click();
|
sortItem!.click();
|
||||||
expect(instance.sortOption.value).toEqual('name');
|
expect(instance.sortOption.value).toEqual('name');
|
||||||
@@ -148,7 +148,7 @@ describe('ContextMenuComponent', async () => {
|
|||||||
|
|
||||||
expect(filterGroup).toBeDefined();
|
expect(filterGroup).toBeDefined();
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-expect-error it is defined
|
||||||
const filterItems = filterGroup.querySelectorAll('.filter-item-label');
|
const filterItems = filterGroup.querySelectorAll('.filter-item-label');
|
||||||
|
|
||||||
if (filterItems.length !== facet.buckets.length) {
|
if (filterItems.length !== facet.buckets.length) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ describe('ContextMenuService', () => {
|
|||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
providers: [ContextMenuService],
|
providers: [ContextMenuService],
|
||||||
});
|
});
|
||||||
service = TestBed.get(ContextMenuService);
|
service = TestBed.inject(ContextMenuService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be created', () => {
|
it('should be created', () => {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
/* eslint-disable unicorn/no-useless-undefined, @typescript-eslint/no-non-null-assertion */
|
||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
import {
|
import {
|
||||||
SCSetting,
|
SCSetting,
|
||||||
@@ -35,15 +36,13 @@ describe('SettingsProvider', () => {
|
|||||||
let scheduleSyncServiceSpy: jasmine.SpyObj<ScheduleSyncService>;
|
let scheduleSyncServiceSpy: jasmine.SpyObj<ScheduleSyncService>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const storageProviderMethodSpy = jasmine.createSpyObj('StorageProvider', [
|
storageProviderSpy = jasmine.createSpyObj('StorageProvider', [
|
||||||
'init',
|
'init',
|
||||||
'get',
|
'get',
|
||||||
'has',
|
'has',
|
||||||
'put',
|
'put',
|
||||||
]);
|
]);
|
||||||
const configProviderMethodSpy = jasmine.createSpyObj('ConfigProvider', [
|
configProviderSpy = jasmine.createSpyObj('ConfigProvider', ['getValue']);
|
||||||
'getValue',
|
|
||||||
]);
|
|
||||||
scheduleSyncServiceSpy = jasmine.createSpyObj('ScheduleSyncService', [
|
scheduleSyncServiceSpy = jasmine.createSpyObj('ScheduleSyncService', [
|
||||||
'getDifferences',
|
'getDifferences',
|
||||||
'postDifferencesNotification',
|
'postDifferencesNotification',
|
||||||
@@ -55,11 +54,11 @@ describe('SettingsProvider', () => {
|
|||||||
SettingsProvider,
|
SettingsProvider,
|
||||||
{
|
{
|
||||||
provide: StorageProvider,
|
provide: StorageProvider,
|
||||||
useValue: storageProviderMethodSpy,
|
useValue: storageProviderSpy,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: ConfigProvider,
|
provide: ConfigProvider,
|
||||||
useValue: configProviderMethodSpy,
|
useValue: configProviderSpy,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: ScheduleSyncService,
|
provide: ScheduleSyncService,
|
||||||
@@ -67,12 +66,10 @@ describe('SettingsProvider', () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
configProviderSpy = TestBed.get(ConfigProvider);
|
|
||||||
// set settings returned from config
|
// set settings returned from config
|
||||||
configProviderSpy.getValue.and.returnValue(CONFIG_SETTINGS_MOCK);
|
configProviderSpy.getValue.and.returnValue(CONFIG_SETTINGS_MOCK);
|
||||||
settingsProvider = TestBed.get(SettingsProvider);
|
settingsProvider = TestBed.inject(SettingsProvider);
|
||||||
storageProviderSpy = TestBed.get(StorageProvider);
|
storageProviderSpy.has.and.returnValue(Promise.resolve(false));
|
||||||
storageProviderMethodSpy.has.and.returnValue(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide and get setting', async () => {
|
it('should provide and get setting', async () => {
|
||||||
@@ -83,7 +80,7 @@ describe('SettingsProvider', () => {
|
|||||||
CONFIG_SETTINGS_MOCK[0].categories[0],
|
CONFIG_SETTINGS_MOCK[0].categories[0],
|
||||||
CONFIG_SETTINGS_MOCK[0].name,
|
CONFIG_SETTINGS_MOCK[0].name,
|
||||||
);
|
);
|
||||||
await expect(setting.value).toBeDefined();
|
expect(setting.value).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide and get settings value', async () => {
|
it('should provide and get settings value', async () => {
|
||||||
@@ -94,7 +91,7 @@ describe('SettingsProvider', () => {
|
|||||||
CONFIG_SETTINGS_MOCK[0].categories[0],
|
CONFIG_SETTINGS_MOCK[0].categories[0],
|
||||||
CONFIG_SETTINGS_MOCK[0].name,
|
CONFIG_SETTINGS_MOCK[0].name,
|
||||||
);
|
);
|
||||||
await expect(value).toEqual(CONFIG_SETTINGS_MOCK[0].defaultValue);
|
expect(value).toEqual(CONFIG_SETTINGS_MOCK[0].defaultValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get persisted setting value', async () => {
|
it('should get persisted setting value', async () => {
|
||||||
@@ -108,7 +105,7 @@ describe('SettingsProvider', () => {
|
|||||||
CONFIG_SETTINGS_MOCK[3].categories[0],
|
CONFIG_SETTINGS_MOCK[3].categories[0],
|
||||||
CONFIG_SETTINGS_MOCK[3].name,
|
CONFIG_SETTINGS_MOCK[3].name,
|
||||||
);
|
);
|
||||||
await expect(value).toEqual(SETTING_VALUES_MOCK.profile.group as string);
|
expect(value).toEqual(SETTING_VALUES_MOCK.profile.group as string);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set default setting value if no persisted value exist', async () => {
|
it('should set default setting value if no persisted value exist', async () => {
|
||||||
@@ -119,7 +116,7 @@ describe('SettingsProvider', () => {
|
|||||||
CONFIG_SETTINGS_MOCK[3].categories[0],
|
CONFIG_SETTINGS_MOCK[3].categories[0],
|
||||||
CONFIG_SETTINGS_MOCK[3].name,
|
CONFIG_SETTINGS_MOCK[3].name,
|
||||||
);
|
);
|
||||||
await expect(value).toEqual(CONFIG_SETTINGS_MOCK[3].defaultValue);
|
expect(value).toEqual(CONFIG_SETTINGS_MOCK[3].defaultValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should keep persisted setting values from settings that are not contained in loaded config', async () => {
|
it('should keep persisted setting values from settings that are not contained in loaded config', async () => {
|
||||||
@@ -130,7 +127,7 @@ describe('SettingsProvider', () => {
|
|||||||
Promise.resolve(SETTING_VALUES_MOCK),
|
Promise.resolve(SETTING_VALUES_MOCK),
|
||||||
);
|
);
|
||||||
await settingsProvider.init();
|
await settingsProvider.init();
|
||||||
await expect(storageProviderSpy.put).toHaveBeenCalledWith(
|
expect(storageProviderSpy.put).toHaveBeenCalledWith(
|
||||||
STORAGE_KEY_SETTING_VALUES,
|
STORAGE_KEY_SETTING_VALUES,
|
||||||
SETTING_VALUES_MOCK,
|
SETTING_VALUES_MOCK,
|
||||||
);
|
);
|
||||||
@@ -149,7 +146,7 @@ describe('SettingsProvider', () => {
|
|||||||
CONFIG_SETTINGS_MOCK[1].categories[0],
|
CONFIG_SETTINGS_MOCK[1].categories[0],
|
||||||
CONFIG_SETTINGS_MOCK[1].name,
|
CONFIG_SETTINGS_MOCK[1].name,
|
||||||
);
|
);
|
||||||
await expect(value).toEqual('updated');
|
expect(value).toEqual('updated');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return copy of settingsCache', async () => {
|
it('should return copy of settingsCache', async () => {
|
||||||
@@ -161,7 +158,7 @@ describe('SettingsProvider', () => {
|
|||||||
const settings = await settingsProvider.getCache();
|
const settings = await settingsProvider.getCache();
|
||||||
settings[category].settings[name].value = 'testValue';
|
settings[category].settings[name].value = 'testValue';
|
||||||
// cached setting value should still be defaultValue
|
// cached setting value should still be defaultValue
|
||||||
await expect(await settingsProvider.getValue(category, name)).toEqual(
|
expect(await settingsProvider.getValue(category, name)).toEqual(
|
||||||
CONFIG_SETTINGS_MOCK[0].defaultValue,
|
CONFIG_SETTINGS_MOCK[0].defaultValue,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -175,12 +172,12 @@ describe('SettingsProvider', () => {
|
|||||||
CONFIG_SETTINGS_MOCK[0].name,
|
CONFIG_SETTINGS_MOCK[0].name,
|
||||||
'',
|
'',
|
||||||
);
|
);
|
||||||
await expect(storageProviderSpy.put).toHaveBeenCalled();
|
expect(storageProviderSpy.put).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should clear settings', async () => {
|
it('should clear settings', async () => {
|
||||||
await settingsProvider.reset();
|
await settingsProvider.reset();
|
||||||
await expect(storageProviderSpy.put).toHaveBeenCalledWith(
|
expect(storageProviderSpy.put).toHaveBeenCalledWith(
|
||||||
STORAGE_KEY_SETTING_VALUES,
|
STORAGE_KEY_SETTING_VALUES,
|
||||||
{},
|
{},
|
||||||
);
|
);
|
||||||
@@ -198,7 +195,7 @@ describe('SettingsProvider', () => {
|
|||||||
CONFIG_SETTINGS_MOCK[0].categories[0],
|
CONFIG_SETTINGS_MOCK[0].categories[0],
|
||||||
CONFIG_SETTINGS_MOCK[0].name,
|
CONFIG_SETTINGS_MOCK[0].name,
|
||||||
);
|
);
|
||||||
await expect(value).toEqual(CONFIG_SETTINGS_MOCK[0].defaultValue);
|
expect(value).toEqual(CONFIG_SETTINGS_MOCK[0].defaultValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should validate wrong values for inputType text', async () => {
|
it('should validate wrong values for inputType text', async () => {
|
||||||
@@ -243,7 +240,7 @@ describe('SettingsProvider', () => {
|
|||||||
* TODO
|
* TODO
|
||||||
*/
|
*/
|
||||||
async function testValue(setting: SCSetting, value: unknown) {
|
async function testValue(setting: SCSetting, value: unknown) {
|
||||||
let error: Error;
|
let error: Error | undefined = undefined;
|
||||||
await settingsProvider.provideSetting(JSON.parse(JSON.stringify(setting)));
|
await settingsProvider.provideSetting(JSON.parse(JSON.stringify(setting)));
|
||||||
try {
|
try {
|
||||||
await settingsProvider.setSettingValue(
|
await settingsProvider.setSettingValue(
|
||||||
@@ -254,12 +251,9 @@ describe('SettingsProvider', () => {
|
|||||||
} catch (error_) {
|
} catch (error_) {
|
||||||
error = error_;
|
error = error_;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-ignore
|
expect(error).toBeDefined();
|
||||||
await expect(error).toBeDefined();
|
expect(error!.message).toMatch(/is not valid/);
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-ignore
|
|
||||||
await expect(error.message).toMatch(/is not valid/);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const CONFIG_SETTINGS_MOCK: SCSetting[] = [
|
const CONFIG_SETTINGS_MOCK: SCSetting[] = [
|
||||||
|
|||||||
@@ -12,8 +12,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/ban-ts-comment */
|
|
||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
import {Storage} from '@ionic/storage-angular';
|
import {Storage} from '@ionic/storage-angular';
|
||||||
import {StorageModule} from './storage.module';
|
import {StorageModule} from './storage.module';
|
||||||
@@ -29,8 +28,8 @@ describe('StorageProvider', () => {
|
|||||||
imports: [StorageModule],
|
imports: [StorageModule],
|
||||||
providers: [StorageProvider],
|
providers: [StorageProvider],
|
||||||
});
|
});
|
||||||
storageProvider = TestBed.get(StorageProvider);
|
storageProvider = TestBed.inject(StorageProvider);
|
||||||
storage = TestBed.get(Storage);
|
storage = TestBed.inject(Storage);
|
||||||
|
|
||||||
sampleEntries = new Map([
|
sampleEntries = new Map([
|
||||||
['foo', 'Bar'],
|
['foo', 'Bar'],
|
||||||
@@ -51,7 +50,7 @@ describe('StorageProvider', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should call ready method of storage on init', async () => {
|
it('should call ready method of storage on init', async () => {
|
||||||
// @ts-ignore
|
// @ts-expect-error no need to return storage for this case
|
||||||
spyOn(storage, 'create').and.callFake(() => Promise.resolve());
|
spyOn(storage, 'create').and.callFake(() => Promise.resolve());
|
||||||
await storageProvider.init();
|
await storageProvider.init();
|
||||||
|
|
||||||
@@ -107,7 +106,7 @@ describe('StorageProvider', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should put multiple values into the storage', async () => {
|
it('should put multiple values into the storage', async () => {
|
||||||
// @ts-ignore
|
// @ts-expect-error no need to return anything for this case
|
||||||
spyOn(storageProvider, 'put').and.callFake(() => Promise.resolve());
|
spyOn(storageProvider, 'put').and.callFake(() => Promise.resolve());
|
||||||
await storageProvider.putMultiple(sampleEntries);
|
await storageProvider.putMultiple(sampleEntries);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user