diff --git a/src/app/shared/testing/utils.test.ts b/src/app/shared/testing/utils.test.ts index e5130d6182d..7285d348463 100644 --- a/src/app/shared/testing/utils.test.ts +++ b/src/app/shared/testing/utils.test.ts @@ -1,4 +1,4 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, MetadataOverride, TestBed } from '@angular/core/testing'; import { buildPaginatedList, PaginatedList } from '../../core/data/paginated-list.model'; import { PageInfo } from '../../core/shared/page-info.model'; import { Observable } from 'rxjs/internal/Observable'; @@ -6,6 +6,7 @@ import { of as observableOf } from 'rxjs/internal/observable/of'; import { UnCacheableObject } from '../../core/shared/uncacheable-object.model'; import { RequestEntryState } from '../../core/data/request-entry-state.model'; import { RequestEntry } from '../../core/data/request-entry.model'; +import { Component } from '@angular/core'; /** * Returns true if a Native Element has a specified css class. @@ -27,10 +28,12 @@ export const hasClass = (element: any, className: string): boolean => { * the component's template as html * @param type * the type of the component to instantiate + * @param override */ -export const createTestComponent = (html: string, type: new (...args: any[]) => T ): ComponentFixture => { +export const createTestComponent = (html: string, type: new (...args: any[]) => T, override: MetadataOverride = {}): ComponentFixture => { TestBed.overrideComponent(type, { - set: { template: html } + set: { template: html }, + ...override }); const fixture = TestBed.createComponent(type); diff --git a/src/test.ts b/src/test.ts index 793ae77de8d..11c74793d2d 100644 --- a/src/test.ts +++ b/src/test.ts @@ -3,13 +3,8 @@ import 'zone.js/testing'; import { getTestBed } from '@angular/core/testing'; import { MockStore } from '@ngrx/store/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; +import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; -import { ThemeService } from './app/shared/theme-support/theme.service'; -import { getMockThemeService } from './app/shared/mocks/theme-service.mock'; // First, initialize the Angular testing environment. getTestBed().initTestEnvironment( @@ -18,9 +13,6 @@ getTestBed().initTestEnvironment( { teardown: { destroyAfterEach: false } } ); -jasmine.getEnv().beforeEach(() => { - getTestBed().overrideProvider(ThemeService, { useValue: getMockThemeService() }); -}); jasmine.getEnv().afterEach(() => { // If store is mocked, reset state after each test (see https://ngrx.io/guide/migration/v13)