fix BitstreamFormatsComponent tests

This commit is contained in:
Enea Jahollari
2023-09-27 14:49:49 +02:00
parent e3abb75a56
commit 1186415bf1

View File

@@ -1,6 +1,6 @@
import { BitstreamFormatsComponent } from './bitstream-formats.component';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { of as observableOf } from 'rxjs';
import { of, of as observableOf } from 'rxjs';
import { CommonModule } from '@angular/common';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core';
@@ -18,14 +18,18 @@ import { BitstreamFormatSupportLevel } from '../../../core/shared/bitstream-form
import { cold, getTestScheduler, hot } from 'jasmine-marbles';
import { TestScheduler } from 'rxjs/testing';
import {
createFailedRemoteDataObject$,
createNoContentRemoteDataObject$,
createSuccessfulRemoteDataObject,
createSuccessfulRemoteDataObject$,
createFailedRemoteDataObject$
createSuccessfulRemoteDataObject$
} from '../../../shared/remote-data.utils';
import { createPaginatedList } from '../../../shared/testing/utils.test';
import { PaginationService } from '../../../core/pagination/pagination.service';
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
import { GroupDataService } from '../../../core/eperson/group-data.service';
import { ConfigurationDataService } from '../../../core/data/configuration-data.service';
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
import { provideMockStore } from '@ngrx/store/testing';
describe('BitstreamFormatsComponent', () => {
let comp: BitstreamFormatsComponent;
@@ -99,16 +103,31 @@ describe('BitstreamFormatsComponent', () => {
clearBitStreamFormatRequests: observableOf('cleared')
});
const groupDataService = jasmine.createSpyObj('groupsDataService', {
findListByHref: createSuccessfulRemoteDataObject$(createPaginatedList([])),
getGroupRegistryRouterLink: '',
getUUIDFromString: '',
});
const configurationDataService = jasmine.createSpyObj('ConfigurationDataService', {
findByPropertyName: of({payload: {value: 'test'}}),
});
paginationService = new PaginationServiceStub();
TestBed.configureTestingModule({
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
providers: [
provideMockStore(),
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
{provide: HostWindowService, useValue: new HostWindowServiceStub(0)},
{provide: NotificationsService, useValue: notificationsServiceStub},
{ provide: PaginationService, useValue: paginationService }
]
{provide: PaginationService, useValue: paginationService},
{provide: GroupDataService, useValue: groupDataService},
{provide: ConfigurationDataService, useValue: configurationDataService}
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
};
@@ -226,17 +245,39 @@ describe('BitstreamFormatsComponent', () => {
clearBitStreamFormatRequests: observableOf('cleared')
});
const groupDataService = jasmine.createSpyObj('groupsDataService', {
findListByHref: createSuccessfulRemoteDataObject$(createPaginatedList([])),
getGroupRegistryRouterLink: '',
getUUIDFromString: '',
});
const configurationDataService = jasmine.createSpyObj('ConfigurationDataService', {
findByPropertyName: of({payload: {value: 'test'}}),
});
paginationService = new PaginationServiceStub();
TestBed.configureTestingModule({
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
imports: [
CommonModule,
RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule,
BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
providers: [
provideMockStore(),
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
{provide: HostWindowService, useValue: new HostWindowServiceStub(0)},
{provide: NotificationsService, useValue: notificationsServiceStub},
{ provide: PaginationService, useValue: paginationService }
]
}).compileComponents();
{provide: PaginationService, useValue: paginationService},
{provide: GroupDataService, useValue: groupDataService},
{provide: ConfigurationDataService, useValue: configurationDataService}
],
schemas: [NO_ERRORS_SCHEMA]
})
.overrideComponent(BitstreamFormatsComponent, {
remove: {imports: [PaginationComponent]},
add: {imports: [TestPaginationComponent]}
})
.compileComponents();
}
));
@@ -274,17 +315,37 @@ describe('BitstreamFormatsComponent', () => {
clearBitStreamFormatRequests: observableOf('cleared')
});
const groupDataService = jasmine.createSpyObj('groupsDataService', {
findListByHref: createSuccessfulRemoteDataObject$(createPaginatedList([])),
getGroupRegistryRouterLink: '',
getUUIDFromString: '',
});
const configurationDataService = jasmine.createSpyObj('ConfigurationDataService', {
findByPropertyName: of({payload: {value: 'test'}}),
});
paginationService = new PaginationServiceStub();
TestBed.configureTestingModule({
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
providers: [
provideMockStore(),
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
{provide: HostWindowService, useValue: new HostWindowServiceStub(0)},
{provide: NotificationsService, useValue: notificationsServiceStub},
{ provide: PaginationService, useValue: paginationService }
]
}).compileComponents();
{provide: PaginationService, useValue: paginationService},
{provide: PaginationService, useValue: paginationService},
{provide: GroupDataService, useValue: groupDataService},
{provide: ConfigurationDataService, useValue: configurationDataService}
],
schemas: [NO_ERRORS_SCHEMA]
})
.overrideComponent(BitstreamFormatsComponent, {
remove: {imports: [PaginationComponent]},
add: {imports: [TestPaginationComponent]}
})
.compileComponents();
}
));
@@ -304,3 +365,12 @@ describe('BitstreamFormatsComponent', () => {
});
});
});
@Component({
exportAs: 'paginationComponent',
selector: 'ds-pagination',
template: ``,
standalone: true,
})
export class TestPaginationComponent {
}