mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
111638: Fix autoRefreshingSearchBy test
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
import { testFindAllDataImplementation } from '../base/find-all-data.spec';
|
||||
import { ProcessDataService, TIMER_FACTORY } from './process-data.service';
|
||||
import { testDeleteDataImplementation } from '../base/delete-data.spec';
|
||||
import { waitForAsync, TestBed, fakeAsync, tick, flush } from '@angular/core/testing';
|
||||
import { waitForAsync, TestBed, fakeAsync, tick } from '@angular/core/testing';
|
||||
import { RequestService } from '../request.service';
|
||||
import { RemoteData } from '../remote-data';
|
||||
import { RequestEntryState } from '../request-entry-state.model';
|
||||
@@ -27,6 +27,7 @@ import { testSearchDataImplementation } from '../base/search-data.spec';
|
||||
import { PaginatedList } from '../paginated-list.model';
|
||||
import { FindListOptions } from '../find-list-options.model';
|
||||
import { of } from 'rxjs';
|
||||
import { getMockRequestService } from '../../../shared/mocks/request.service.mock';
|
||||
|
||||
describe('ProcessDataService', () => {
|
||||
let testScheduler;
|
||||
@@ -43,7 +44,7 @@ describe('ProcessDataService', () => {
|
||||
testSearchDataImplementation(initService);
|
||||
});
|
||||
|
||||
let requestService;
|
||||
let requestService = getMockRequestService();
|
||||
let processDataService;
|
||||
let remoteDataBuildService;
|
||||
|
||||
@@ -136,7 +137,7 @@ describe('ProcessDataService', () => {
|
||||
imports: [],
|
||||
providers: [
|
||||
ProcessDataService,
|
||||
{ provide: RequestService, useValue: null },
|
||||
{ provide: RequestService, useValue: requestService },
|
||||
{ provide: RemoteDataBuildService, useValue: null },
|
||||
{ provide: ObjectCacheService, useValue: null },
|
||||
{ provide: ReducerManager, useValue: null },
|
||||
@@ -172,21 +173,21 @@ describe('ProcessDataService', () => {
|
||||
|
||||
const runningProcessRD = new RemoteData(0, 0, 0, RequestEntryState.Success, null, runningProcessPagination);
|
||||
|
||||
spyOn(processDataService, 'invalidateByHref');
|
||||
spyOn(processDataService, 'searchBy').and.returnValue(
|
||||
of(runningProcessRD)
|
||||
);
|
||||
|
||||
let sub = processDataService.autoRefreshingSearchBy('byProperty', new FindListOptions(), 200).subscribe();
|
||||
tick(0);
|
||||
expect(processDataService.searchBy).toHaveBeenCalledTimes(0);
|
||||
expect(requestService.setStaleByHrefSubstring).toHaveBeenCalledTimes(0);
|
||||
|
||||
let sub = processDataService.autoRefreshingSearchBy('id', 'byProperty', new FindListOptions(), 200).subscribe();
|
||||
expect(processDataService.searchBy).toHaveBeenCalledTimes(1);
|
||||
tick(450);
|
||||
expect(processDataService.searchBy).toHaveBeenCalledTimes(3);
|
||||
|
||||
tick(250);
|
||||
|
||||
expect(requestService.setStaleByHrefSubstring).toHaveBeenCalledTimes(1);
|
||||
|
||||
sub.unsubscribe();
|
||||
|
||||
flush();
|
||||
|
||||
expect(processDataService.invalidateByHref).toHaveBeenCalledTimes(3);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user