mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 22:13:02 +00:00
94273: Implement dependencies between requests
When an object is invalidated, its dependent requests are invalidated as well
This commit is contained in:
28
src/app/core/cache/object-cache.reducer.spec.ts
vendored
28
src/app/core/cache/object-cache.reducer.spec.ts
vendored
@@ -2,11 +2,13 @@ import * as deepFreeze from 'deep-freeze';
|
||||
import { Operation } from 'fast-json-patch';
|
||||
import { Item } from '../shared/item.model';
|
||||
import {
|
||||
AddDependentsObjectCacheAction,
|
||||
AddPatchObjectCacheAction,
|
||||
AddToObjectCacheAction,
|
||||
ApplyPatchObjectCacheAction,
|
||||
RemoveDependentsObjectCacheAction,
|
||||
RemoveFromObjectCacheAction,
|
||||
ResetObjectCacheTimestampsAction
|
||||
ResetObjectCacheTimestampsAction,
|
||||
} from './object-cache.actions';
|
||||
|
||||
import { objectCacheReducer } from './object-cache.reducer';
|
||||
@@ -42,20 +44,22 @@ describe('objectCacheReducer', () => {
|
||||
timeCompleted: new Date().getTime(),
|
||||
msToLive: 900000,
|
||||
requestUUIDs: [requestUUID1],
|
||||
dependentRequestUUIDs: [],
|
||||
patches: [],
|
||||
isDirty: false,
|
||||
},
|
||||
[selfLink2]: {
|
||||
data: {
|
||||
type: Item.type,
|
||||
self: requestUUID2,
|
||||
self: selfLink2,
|
||||
foo: 'baz',
|
||||
_links: { self: { href: requestUUID2 } }
|
||||
_links: { self: { href: selfLink2 } }
|
||||
},
|
||||
alternativeLinks: [altLink3, altLink4],
|
||||
timeCompleted: new Date().getTime(),
|
||||
msToLive: 900000,
|
||||
requestUUIDs: [selfLink2],
|
||||
requestUUIDs: [requestUUID2],
|
||||
dependentRequestUUIDs: [requestUUID1],
|
||||
patches: [],
|
||||
isDirty: false
|
||||
}
|
||||
@@ -189,4 +193,20 @@ describe('objectCacheReducer', () => {
|
||||
expect((newState[selfLink1].data as any).name).toEqual(newName);
|
||||
});
|
||||
|
||||
it('should add dependent requests on ADD_DEPENDENTS', () => {
|
||||
let newState = objectCacheReducer(testState, new AddDependentsObjectCacheAction(selfLink1, ['new', 'newer', 'newest']));
|
||||
expect(newState[selfLink1].dependentRequestUUIDs).toEqual(['new', 'newer', 'newest']);
|
||||
|
||||
newState = objectCacheReducer(newState, new AddDependentsObjectCacheAction(selfLink2, ['more']));
|
||||
expect(newState[selfLink2].dependentRequestUUIDs).toEqual([requestUUID1, 'more']);
|
||||
});
|
||||
|
||||
it('should clear dependent requests on REMOVE_DEPENDENTS', () => {
|
||||
let newState = objectCacheReducer(testState, new RemoveDependentsObjectCacheAction(selfLink1));
|
||||
expect(newState[selfLink1].dependentRequestUUIDs).toEqual([]);
|
||||
|
||||
newState = objectCacheReducer(newState, new RemoveDependentsObjectCacheAction(selfLink2));
|
||||
expect(newState[selfLink2].dependentRequestUUIDs).toEqual([]);
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user