mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 14:03:06 +00:00
Add tests and fix tests
This commit is contained in:
@@ -13,6 +13,10 @@ import { CollectionSelectComponent } from './collection-select.component';
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../remote-data.utils';
|
||||
import { createPaginatedList } from '../../testing/utils.test';
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../core/data/request.models';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
|
||||
describe('CollectionSelectComponent', () => {
|
||||
let comp: CollectionSelectComponent;
|
||||
@@ -36,13 +40,24 @@ describe('CollectionSelectComponent', () => {
|
||||
currentPage: 1
|
||||
});
|
||||
|
||||
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 paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
});
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), SharedModule, RouterTestingModule.withRoutes([])],
|
||||
declarations: [],
|
||||
providers: [
|
||||
{ provide: ObjectSelectService, useValue: new ObjectSelectServiceStub([mockCollectionList[1].id]) },
|
||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) }
|
||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
||||
{ provide: PaginationService, useValue: paginationService }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
|
@@ -11,14 +11,18 @@ import { HostWindowService } from '../../host-window.service';
|
||||
import { HostWindowServiceStub } from '../../testing/host-window-service.stub';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { of } from 'rxjs';
|
||||
import { of as observableOf, of } from 'rxjs';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../remote-data.utils';
|
||||
import { createPaginatedList } from '../../testing/utils.test';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../core/data/request.models';
|
||||
|
||||
describe('ItemSelectComponent', () => {
|
||||
let comp: ItemSelectComponent;
|
||||
let fixture: ComponentFixture<ItemSelectComponent>;
|
||||
let objectSelectService: ObjectSelectService;
|
||||
let paginationService: PaginationService;
|
||||
|
||||
const mockItemList = [
|
||||
Object.assign(new Item(), {
|
||||
@@ -59,13 +63,25 @@ describe('ItemSelectComponent', () => {
|
||||
currentPage: 1
|
||||
});
|
||||
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(mockPaginationOptions),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
});
|
||||
|
||||
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), SharedModule, RouterTestingModule.withRoutes([])],
|
||||
declarations: [],
|
||||
providers: [
|
||||
{ provide: ObjectSelectService, useValue: new ObjectSelectServiceStub([mockItemList[1].id]) },
|
||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) }
|
||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
||||
{ provide: PaginationService, useValue: paginationService }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
|
Reference in New Issue
Block a user