fix: daia availability

This commit is contained in:
Jovan Krunić
2022-09-20 13:58:32 +00:00
committed by Rainer Killinger
parent b38a96996a
commit 13cee2d426
16 changed files with 240 additions and 158 deletions

View File

@@ -23,7 +23,7 @@ import {LoggerConfig, LoggerModule, NGXLogger} from 'ngx-logger';
import {MapModule} from '../map/map.module';
import {HttpClientModule} from '@angular/common/http';
import {StorageModule} from '../storage/storage.module';
import {SCDaiaHolding, SCDaiaService} from './protocol/response';
import {DaiaHolding, DaiaService} from './protocol/response';
import {Observable, of} from 'rxjs';
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
@@ -69,9 +69,9 @@ describe('DaiaDataProvider', () => {
});
describe('getResourceLink', () => {
it('should return undefined when available not defined', () => {
const holding: SCDaiaHolding = {
const holding: DaiaHolding = {
department: {id: '', content: ''},
id: '',
label: '',
online: false,
signature: '',
};
@@ -80,16 +80,16 @@ describe('DaiaDataProvider', () => {
});
it('should return the resource link without proxy when service is openaccess', () => {
const available: SCDaiaService = {
const available: DaiaService = {
delay: '',
expected: '',
href: 'https://some-url.com',
limitations: [],
service: 'openaccess',
};
const holding: SCDaiaHolding = {
const holding: DaiaHolding = {
department: {id: '', content: ''},
id: '',
label: '',
online: false,
signature: '',
available: available,
@@ -99,16 +99,16 @@ describe('DaiaDataProvider', () => {
});
it('should return the resource link with proxy when service is not openaccess', () => {
const available: SCDaiaService = {
const available: DaiaService = {
delay: '',
expected: '',
href: 'https://some-url.com',
limitations: [],
service: 'other',
};
const holding: SCDaiaHolding = {
const holding: DaiaHolding = {
department: {id: '', content: ''},
id: '',
label: '',
online: false,
signature: '',
available: available,
@@ -124,51 +124,51 @@ describe('DaiaDataProvider', () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// let available, unavalable: SCDaiaService[];
const checkedOut: SCDaiaService = {
const checkedOut: DaiaService = {
expected: '2022-09-01',
limitations: [],
service: 'loan',
};
const notYetAvailableOnBuy: SCDaiaService = {
const notYetAvailableOnBuy: DaiaService = {
limitations: [{id: 'OnBuy', content: ''}],
service: 'loan',
};
const notYetAvailableJustReturned: SCDaiaService = {
const notYetAvailableJustReturned: DaiaService = {
limitations: [{id: 'JustReturned', content: ''}],
service: 'loan',
};
const notAvailableCopyIsMissing: SCDaiaService = {
const notAvailableCopyIsMissing: DaiaService = {
limitations: [{id: 'CopyIsMissing', content: ''}],
service: 'loan',
};
const notAvailableCanceled: SCDaiaService = {
const notAvailableCanceled: DaiaService = {
limitations: [{id: 'Canceled', content: ''}],
service: 'loan',
};
const libraryOnlyOnlyInHouse: SCDaiaService = {
const libraryOnlyOnlyInHouse: DaiaService = {
limitations: [{id: 'OnlyInHouse', content: ''}],
service: 'loan',
};
const libraryOnlyExternalLoan: SCDaiaService = {
const libraryOnlyExternalLoan: DaiaService = {
limitations: [{id: 'ExternalLoan', content: ''}],
service: 'loan',
};
const libraryOnlyNoLimitations: SCDaiaService = {
const libraryOnlyPresentation: DaiaService = {
service: 'presentation',
};
const availableLimitationsUndefined: DaiaService = {
service: 'loan',
};
const availableLimitationsUndefined: SCDaiaService = {
service: 'loan',
};
const availableLimitationsEmpty: SCDaiaService = {
const availableLimitationsEmpty: DaiaService = {
limitations: [],
service: 'loan',
};
@@ -205,21 +205,27 @@ describe('DaiaDataProvider', () => {
daiaDataProvider.getHoldingStatus([libraryOnlyExternalLoan], []),
).toEqual('library_only');
expect(
daiaDataProvider.getHoldingStatus([], [libraryOnlyNoLimitations]),
daiaDataProvider.getHoldingStatus([libraryOnlyPresentation], []),
).toEqual('library_only');
});
it('should return available', () => {
expect(
daiaDataProvider.getHoldingStatus([availableLimitationsUndefined], []),
daiaDataProvider.getHoldingStatus(
[availableLimitationsUndefined, libraryOnlyPresentation],
[],
),
).toEqual('available');
expect(
daiaDataProvider.getHoldingStatus([availableLimitationsEmpty], []),
daiaDataProvider.getHoldingStatus(
[availableLimitationsEmpty, libraryOnlyPresentation],
[],
),
).toEqual('available');
});
it('should return unknown otherwise', () => {
const withoutLoan: SCDaiaService = {
const withoutLoan: DaiaService = {
limitations: [],
service: 'anything else',
};
@@ -230,6 +236,12 @@ describe('DaiaDataProvider', () => {
expect(daiaDataProvider.getHoldingStatus([], [withoutLoan])).toEqual(
'unknown',
);
expect(
daiaDataProvider.getHoldingStatus([], [availableLimitationsUndefined]),
).toEqual('unknown');
expect(
daiaDataProvider.getHoldingStatus([], [availableLimitationsEmpty]),
).toEqual('unknown');
});
});
});