Fix tests

This commit is contained in:
Yana De Pauw
2022-04-26 16:40:38 +02:00
parent c63a25b18e
commit d8b6e65f6f
6 changed files with 20 additions and 5 deletions

View File

@@ -20,6 +20,8 @@ import { FeatureID } from '../../core/data/feature-authorization/feature-id';
import createSpy = jasmine.createSpy; import createSpy = jasmine.createSpy;
import { createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils'; import { createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils';
import { Item } from '../../core/shared/item.model'; import { Item } from '../../core/shared/item.model';
import { ThemeService } from '../../shared/theme-support/theme.service';
import { getMockThemeService } from '../../shared/mocks/theme-service.mock';
describe('AdminSidebarComponent', () => { describe('AdminSidebarComponent', () => {
let comp: AdminSidebarComponent; let comp: AdminSidebarComponent;
@@ -60,6 +62,7 @@ describe('AdminSidebarComponent', () => {
declarations: [AdminSidebarComponent], declarations: [AdminSidebarComponent],
providers: [ providers: [
Injector, Injector,
{ provide: ThemeService, useValue: getMockThemeService() },
{ provide: MenuService, useValue: menuService }, { provide: MenuService, useValue: menuService },
{ provide: CSSVariableService, useClass: CSSVariableServiceStub }, { provide: CSSVariableService, useClass: CSSVariableServiceStub },
{ provide: AuthService, useClass: AuthServiceStub }, { provide: AuthService, useClass: AuthServiceStub },

View File

@@ -1,6 +1,8 @@
import { NO_ERRORS_SCHEMA } from '@angular/core'; import { NO_ERRORS_SCHEMA } from '@angular/core';
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { ImportExternalPageComponent } from './import-external-page.component'; import { ImportExternalPageComponent } from './import-external-page.component';
import { ThemeService } from '../shared/theme-support/theme.service';
import { getMockThemeService } from '../shared/mocks/theme-service.mock';
describe('ImportExternalPageComponent', () => { describe('ImportExternalPageComponent', () => {
let component: ImportExternalPageComponent; let component: ImportExternalPageComponent;
@@ -9,6 +11,9 @@ describe('ImportExternalPageComponent', () => {
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ImportExternalPageComponent ], declarations: [ ImportExternalPageComponent ],
providers:[
{ provide: ThemeService, useValue: getMockThemeService() },
],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA]
}) })
.compileComponents(); .compileComponents();

View File

@@ -27,6 +27,8 @@ import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } f
import { createPaginatedList } from '../../../shared/testing/utils.test'; import { createPaginatedList } from '../../../shared/testing/utils.test';
import { RelationshipTypeService } from '../../../core/data/relationship-type.service'; import { RelationshipTypeService } from '../../../core/data/relationship-type.service';
import { relationshipTypes } from '../../../shared/testing/relationship-types.mock'; import { relationshipTypes } from '../../../shared/testing/relationship-types.mock';
import { ThemeService } from '../../../shared/theme-support/theme.service';
import { getMockThemeService } from '../../../shared/mocks/theme-service.mock';
let comp: any; let comp: any;
let fixture: ComponentFixture<ItemRelationshipsComponent>; let fixture: ComponentFixture<ItemRelationshipsComponent>;
@@ -211,6 +213,7 @@ describe('ItemRelationshipsComponent', () => {
imports: [SharedModule, TranslateModule.forRoot()], imports: [SharedModule, TranslateModule.forRoot()],
declarations: [ItemRelationshipsComponent], declarations: [ItemRelationshipsComponent],
providers: [ providers: [
{ provide: ThemeService, useValue: getMockThemeService() },
{ provide: ItemDataService, useValue: itemService }, { provide: ItemDataService, useValue: itemService },
{ provide: ObjectUpdatesService, useValue: objectUpdatesService }, { provide: ObjectUpdatesService, useValue: objectUpdatesService },
{ provide: Router, useValue: router }, { provide: Router, useValue: router },

View File

@@ -20,6 +20,8 @@ import { BrowseDefinition } from '../core/shared/browse-definition.model';
import { BrowseByDataType } from '../browse-by/browse-by-switcher/browse-by-decorator'; import { BrowseByDataType } from '../browse-by/browse-by-switcher/browse-by-decorator';
import { Item } from '../core/shared/item.model'; import { Item } from '../core/shared/item.model';
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service'; import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
import { ThemeService } from '../shared/theme-support/theme.service';
import { getMockThemeService } from '../shared/mocks/theme-service.mock';
let comp: NavbarComponent; let comp: NavbarComponent;
let fixture: ComponentFixture<NavbarComponent>; let fixture: ComponentFixture<NavbarComponent>;
@@ -91,6 +93,7 @@ describe('NavbarComponent', () => {
declarations: [NavbarComponent], declarations: [NavbarComponent],
providers: [ providers: [
Injector, Injector,
{ provide: ThemeService, useValue: getMockThemeService() },
{ provide: MenuService, useValue: menuService }, { provide: MenuService, useValue: menuService },
{ provide: HostWindowService, useValue: new HostWindowServiceStub(800) }, { provide: HostWindowService, useValue: new HostWindowServiceStub(800) },
{ provide: ActivatedRoute, useValue: routeStub }, { provide: ActivatedRoute, useValue: routeStub },

View File

@@ -31,6 +31,7 @@ import { BrowseEntry } from '../../core/shared/browse-entry.model';
import { ITEM } from '../../core/shared/item.resource-type'; import { ITEM } from '../../core/shared/item.resource-type';
import { ThemeService } from '../theme-support/theme.service'; import { ThemeService } from '../theme-support/theme.service';
import SpyObj = jasmine.SpyObj; import SpyObj = jasmine.SpyObj;
import { getMockThemeService } from '../mocks/theme-service.mock';
@listableObjectComponent(BrowseEntry, ViewMode.ListElement, DEFAULT_CONTEXT, 'custom') @listableObjectComponent(BrowseEntry, ViewMode.ListElement, DEFAULT_CONTEXT, 'custom')
@Component({ @Component({
@@ -73,13 +74,10 @@ describe('BrowseByComponent', () => {
}); });
const paginationService = new PaginationServiceStub(paginationConfig); const paginationService = new PaginationServiceStub(paginationConfig);
let themeService: SpyObj<ThemeService>; let themeService;
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
themeService = jasmine.createSpyObj('themeService', { themeService = getMockThemeService('dspace');
getThemeName: 'dspace',
getThemeName$: observableOf('dspace'),
});
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CommonModule, CommonModule,

View File

@@ -13,6 +13,8 @@ import { MenuID } from './initial-menus-state';
import { Item } from '../../core/shared/item.model'; import { Item } from '../../core/shared/item.model';
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service'; import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
import { createSuccessfulRemoteDataObject } from '../remote-data.utils'; import { createSuccessfulRemoteDataObject } from '../remote-data.utils';
import { ThemeService } from '../theme-support/theme.service';
import { getMockThemeService } from '../mocks/theme-service.mock';
describe('MenuComponent', () => { describe('MenuComponent', () => {
let comp: MenuComponent; let comp: MenuComponent;
@@ -57,6 +59,7 @@ describe('MenuComponent', () => {
declarations: [MenuComponent], declarations: [MenuComponent],
providers: [ providers: [
Injector, Injector,
{ provide: ThemeService, useValue: getMockThemeService() },
{ provide: MenuService, useClass: MenuServiceStub }, { provide: MenuService, useClass: MenuServiceStub },
{ provide: AuthorizationDataService, useValue: authorizationService }, { provide: AuthorizationDataService, useValue: authorizationService },
{ provide: ActivatedRoute, useValue: routeStub }, { provide: ActivatedRoute, useValue: routeStub },