mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 04:53:06 +00:00
Add tests and fix tests
This commit is contained in:
@@ -12,6 +12,11 @@ import { By } from '@angular/platform-browser';
|
||||
import { ProcessStatus } from '../processes/process-status.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||
import { createPaginatedList } from '../../shared/testing/utils.test';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
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';
|
||||
|
||||
describe('ProcessOverviewComponent', () => {
|
||||
let component: ProcessOverviewComponent;
|
||||
@@ -19,10 +24,15 @@ describe('ProcessOverviewComponent', () => {
|
||||
|
||||
let processService: ProcessDataService;
|
||||
let ePersonService: EPersonDataService;
|
||||
let paginationService: PaginationService;
|
||||
|
||||
let processes: Process[];
|
||||
let ePerson: EPerson;
|
||||
|
||||
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 });
|
||||
|
||||
function init() {
|
||||
processes = [
|
||||
Object.assign(new Process(), {
|
||||
@@ -69,6 +79,12 @@ describe('ProcessOverviewComponent', () => {
|
||||
ePersonService = jasmine.createSpyObj('ePersonService', {
|
||||
findById: createSuccessfulRemoteDataObject$(ePerson)
|
||||
});
|
||||
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
});
|
||||
}
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
@@ -78,7 +94,8 @@ describe('ProcessOverviewComponent', () => {
|
||||
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])],
|
||||
providers: [
|
||||
{ provide: ProcessDataService, useValue: processService },
|
||||
{ provide: EPersonDataService, useValue: ePersonService }
|
||||
{ provide: EPersonDataService, useValue: ePersonService },
|
||||
{ provide: PaginationService, useValue: paginationService }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
@@ -143,16 +160,4 @@ describe('ProcessOverviewComponent', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('onPageChange', () => {
|
||||
const toPage = 2;
|
||||
|
||||
beforeEach(() => {
|
||||
component.onPageChange(toPage);
|
||||
});
|
||||
|
||||
it('should call a new findAll with the corresponding page', () => {
|
||||
expect(processService.findAll).toHaveBeenCalledWith(jasmine.objectContaining({ currentPage: toPage }));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user