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