mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 13:03:04 +00:00
small fixes
This commit is contained in:
@@ -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 { buildPaginatedList, PaginatedList } from '../../core/data/paginated-list.model';
|
||||||
import { PageInfo } from '../../core/shared/page-info.model';
|
import { PageInfo } from '../../core/shared/page-info.model';
|
||||||
import { Observable } from 'rxjs/internal/Observable';
|
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 { UnCacheableObject } from '../../core/shared/uncacheable-object.model';
|
||||||
import { RequestEntryState } from '../../core/data/request-entry-state.model';
|
import { RequestEntryState } from '../../core/data/request-entry-state.model';
|
||||||
import { RequestEntry } from '../../core/data/request-entry.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.
|
* 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
|
* the component's template as html
|
||||||
* @param type
|
* @param type
|
||||||
* the type of the component to instantiate
|
* the type of the component to instantiate
|
||||||
|
* @param override
|
||||||
*/
|
*/
|
||||||
export const createTestComponent = <T>(html: string, type: new (...args: any[]) => T ): ComponentFixture<T> => {
|
export const createTestComponent = <T>(html: string, type: new (...args: any[]) => T, override: MetadataOverride<Component> = {}): ComponentFixture<T> => {
|
||||||
TestBed.overrideComponent(type, {
|
TestBed.overrideComponent(type, {
|
||||||
set: { template: html }
|
set: { template: html },
|
||||||
|
...override
|
||||||
});
|
});
|
||||||
const fixture = TestBed.createComponent(type);
|
const fixture = TestBed.createComponent(type);
|
||||||
|
|
||||||
|
10
src/test.ts
10
src/test.ts
@@ -3,13 +3,8 @@
|
|||||||
import 'zone.js/testing';
|
import 'zone.js/testing';
|
||||||
import { getTestBed } from '@angular/core/testing';
|
import { getTestBed } from '@angular/core/testing';
|
||||||
import { MockStore } from '@ngrx/store/testing';
|
import { MockStore } from '@ngrx/store/testing';
|
||||||
import {
|
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
||||||
BrowserDynamicTestingModule,
|
|
||||||
platformBrowserDynamicTesting
|
|
||||||
} from '@angular/platform-browser-dynamic/testing';
|
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
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.
|
// First, initialize the Angular testing environment.
|
||||||
getTestBed().initTestEnvironment(
|
getTestBed().initTestEnvironment(
|
||||||
@@ -18,9 +13,6 @@ getTestBed().initTestEnvironment(
|
|||||||
{ teardown: { destroyAfterEach: false } }
|
{ teardown: { destroyAfterEach: false } }
|
||||||
);
|
);
|
||||||
|
|
||||||
jasmine.getEnv().beforeEach(() => {
|
|
||||||
getTestBed().overrideProvider(ThemeService, { useValue: getMockThemeService() });
|
|
||||||
});
|
|
||||||
|
|
||||||
jasmine.getEnv().afterEach(() => {
|
jasmine.getEnv().afterEach(() => {
|
||||||
// If store is mocked, reset state after each test (see https://ngrx.io/guide/migration/v13)
|
// If store is mocked, reset state after each test (see https://ngrx.io/guide/migration/v13)
|
||||||
|
Reference in New Issue
Block a user