Add tests and fix tests

This commit is contained in:
Yana De Pauw
2021-03-04 17:10:01 +01:00
parent d07f44ac41
commit b18f9c7c9f
47 changed files with 937 additions and 454 deletions

View File

@@ -23,6 +23,10 @@ import {
createSuccessfulRemoteDataObject$
} from '../../../shared/remote-data.utils';
import { createPaginatedList } from '../../../shared/testing/utils.test';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
import { FindListOptions } from '../../../core/data/request.models';
import { PaginationService } from '../../../core/pagination/pagination.service';
describe('BitstreamFormatsComponent', () => {
let comp: BitstreamFormatsComponent;
@@ -30,6 +34,7 @@ describe('BitstreamFormatsComponent', () => {
let bitstreamFormatService;
let scheduler: TestScheduler;
let notificationsServiceStub;
let paginationService;
const bitstreamFormat1 = new BitstreamFormat();
bitstreamFormat1.uuid = 'test-uuid-1';
@@ -79,6 +84,10 @@ describe('BitstreamFormatsComponent', () => {
];
const mockFormatsRD = createSuccessfulRemoteDataObject(createPaginatedList(mockFormatsList));
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
const sort = new SortOptions('score', SortDirection.DESC);
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
const initAsync = () => {
notificationsServiceStub = new NotificationsServiceStub();
@@ -95,13 +104,23 @@ describe('BitstreamFormatsComponent', () => {
clearBitStreamFormatRequests: observableOf('cleared')
});
paginationService = jasmine.createSpyObj('PaginationService', {
getCurrentPagination: observableOf(pagination),
getCurrentSort: observableOf(sort),
getFindListOptions: observableOf(findlistOptions),
resetPage: {},
});
TestBed.configureTestingModule({
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
declarations: [BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
providers: [
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
{ provide: NotificationsService, useValue: notificationsServiceStub }
{ provide: NotificationsService, useValue: notificationsServiceStub },
{ provide: PaginationService, useValue: paginationService }
]
}).compileComponents();
};
@@ -217,13 +236,23 @@ describe('BitstreamFormatsComponent', () => {
clearBitStreamFormatRequests: observableOf('cleared')
});
TestBed.configureTestingModule({
paginationService = jasmine.createSpyObj('PaginationService', {
getCurrentPagination: observableOf(pagination),
getCurrentSort: observableOf(sort),
getFindListOptions: observableOf(findlistOptions),
resetPage: {},
});
TestBed.configureTestingModule({
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
declarations: [BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
providers: [
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
{ provide: NotificationsService, useValue: notificationsServiceStub }
{ provide: NotificationsService, useValue: notificationsServiceStub },
{ provide: PaginationService, useValue: paginationService }
]
}).compileComponents();
}
@@ -263,13 +292,22 @@ describe('BitstreamFormatsComponent', () => {
clearBitStreamFormatRequests: observableOf('cleared')
});
TestBed.configureTestingModule({
paginationService = jasmine.createSpyObj('PaginationService', {
getCurrentPagination: observableOf(pagination),
getCurrentSort: observableOf(sort),
getFindListOptions: observableOf(findlistOptions),
resetPage: {},
});
TestBed.configureTestingModule({
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
declarations: [BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
providers: [
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
{ provide: NotificationsService, useValue: notificationsServiceStub }
{ provide: NotificationsService, useValue: notificationsServiceStub },
{ provide: PaginationService, useValue: paginationService }
]
}).compileComponents();
}