mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
fix unit tests for bitstream-data.service.ts
This commit is contained in:

committed by
Tim Donohue

parent
eac787f1f4
commit
b184db7a99
@@ -22,6 +22,8 @@ import objectContaining = jasmine.objectContaining;
|
||||
import { RemoteData } from './remote-data';
|
||||
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||
import { RequestParam } from '../cache/models/request-param.model';
|
||||
import { RestResponse } from '../cache/response.models';
|
||||
import { RequestEntry } from './request-entry.model';
|
||||
|
||||
describe('BitstreamDataService', () => {
|
||||
let service: BitstreamDataService;
|
||||
@@ -31,6 +33,7 @@ describe('BitstreamDataService', () => {
|
||||
let bitstreamFormatService: BitstreamFormatDataService;
|
||||
let rdbService: RemoteDataBuildService;
|
||||
const bitstreamFormatHref = 'rest-api/bitstreamformats';
|
||||
let responseCacheEntry: RequestEntry;
|
||||
|
||||
const bitstream1 = Object.assign(new Bitstream(), {
|
||||
id: 'fake-bitstream1',
|
||||
@@ -55,8 +58,13 @@ describe('BitstreamDataService', () => {
|
||||
const url = 'fake-bitstream-url';
|
||||
|
||||
beforeEach(() => {
|
||||
responseCacheEntry = new RequestEntry();
|
||||
responseCacheEntry.request = { href: 'https://rest.api/' } as any;
|
||||
responseCacheEntry.response = new RestResponse(true, 200, 'Success');
|
||||
|
||||
objectCache = jasmine.createSpyObj('objectCache', {
|
||||
remove: jasmine.createSpy('remove')
|
||||
remove: jasmine.createSpy('remove'),
|
||||
getByHref: observableOf(responseCacheEntry),
|
||||
});
|
||||
requestService = getMockRequestService();
|
||||
halService = Object.assign(new HALEndpointServiceStub(url));
|
||||
|
@@ -147,9 +147,11 @@ export class BitstreamDataService extends IdentifiableDataService<Bitstream> imp
|
||||
this.requestService.setStaleByHrefSubstring(bitsreamFormatUrl);
|
||||
// Delete also cache by uuid as the format could be cached also there
|
||||
this.objectCache.getByHref(bitsreamFormatUrl).pipe(take(1)).subscribe((cachedRequest) => {
|
||||
const requestUuid = cachedRequest.requestUUIDs[0];
|
||||
if (this.requestService.hasByUUID(requestUuid)) {
|
||||
this.requestService.setStaleByUUID(requestUuid);
|
||||
if (cachedRequest.requestUUIDs && cachedRequest.requestUUIDs.length > 0){
|
||||
const requestUuid = cachedRequest.requestUUIDs[0];
|
||||
if (this.requestService.hasByUUID(requestUuid)) {
|
||||
this.requestService.setStaleByUUID(requestUuid);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user