mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-09 19:13:08 +00:00
Add tests and fix tests
This commit is contained in:
@@ -11,11 +11,18 @@ import { VersionHistoryDataService } from '../../../core/data/version-history-da
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../remote-data.utils';
|
||||
import { createPaginatedList } from '../../testing/utils.test';
|
||||
import { PaginationComponentOptions } from '../../pagination/pagination-component-options.model';
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
|
||||
describe('ItemVersionsComponent', () => {
|
||||
let component: ItemVersionsComponent;
|
||||
let fixture: ComponentFixture<ItemVersionsComponent>;
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
|
||||
const versionHistory = Object.assign(new VersionHistory(), {
|
||||
id: '1'
|
||||
});
|
||||
@@ -52,12 +59,19 @@ describe('ItemVersionsComponent', () => {
|
||||
getVersions: createSuccessfulRemoteDataObject$(createPaginatedList(versions))
|
||||
});
|
||||
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getRouteParameterValue: observableOf('')
|
||||
});
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ItemVersionsComponent, VarDirective],
|
||||
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])],
|
||||
providers: [
|
||||
{ provide: VersionHistoryDataService, useValue: versionHistoryService }
|
||||
{ provide: VersionHistoryDataService, useValue: versionHistoryService },
|
||||
{ provide: PaginationService, useValue: paginationService }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
@@ -107,16 +121,4 @@ describe('ItemVersionsComponent', () => {
|
||||
expect(summary.nativeElement.textContent).toEqual(version.summary);
|
||||
});
|
||||
});
|
||||
|
||||
describe('switchPage', () => {
|
||||
const page = 5;
|
||||
|
||||
beforeEach(() => {
|
||||
component.switchPage(page);
|
||||
});
|
||||
|
||||
it('should set the option\'s currentPage to the new page', () => {
|
||||
expect(component.options.currentPage).toEqual(page);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user