mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 08:33:11 +00:00
test: inject instead of deprecated TestBed get
Additionally refactor tests and ts-ignore annotations.
This commit is contained in:
@@ -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
|
||||
* 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
|
||||
* 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 {Client} from '@openstapps/api/lib/client';
|
||||
import {
|
||||
@@ -85,8 +85,8 @@ describe('DataProvider', () => {
|
||||
imports: [DataModule],
|
||||
providers: [DataProvider, StAppsWebHttpClient],
|
||||
});
|
||||
storageProvider = TestBed.get(StorageProvider);
|
||||
dataProvider = TestBed.get(DataProvider);
|
||||
storageProvider = TestBed.inject(StorageProvider);
|
||||
dataProvider = TestBed.inject(DataProvider);
|
||||
});
|
||||
|
||||
it('should generate data key', async () => {
|
||||
@@ -146,13 +146,14 @@ describe('DataProvider', () => {
|
||||
for (const key in request_) {
|
||||
if (request_.hasOwnProperty(key)) {
|
||||
i++;
|
||||
// @ts-ignore
|
||||
|
||||
expect(requestCheck[key]).not.toBeNull();
|
||||
expect(requestCheck[key]).toEqual(request_[key]);
|
||||
// @ts-ignore
|
||||
|
||||
// @ts-expect-error is not null
|
||||
// eslint-disable-next-line unicorn/no-null
|
||||
requestCheck[key] = null;
|
||||
// @ts-ignore
|
||||
// @ts-expect-error is a string for test purposes
|
||||
request_[key] = request_[key].toUpperCase();
|
||||
}
|
||||
}
|
||||
@@ -164,7 +165,7 @@ describe('DataProvider', () => {
|
||||
);
|
||||
const response = await dataProvider.multiSearch(request);
|
||||
|
||||
// @ts-ignore
|
||||
// @ts-expect-error same type
|
||||
expect(response).toEqual(responseShould);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user