mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
Forgot to revert test after reverting the ObjectCacheService
This commit is contained in:
14
src/app/core/cache/object-cache.service.spec.ts
vendored
14
src/app/core/cache/object-cache.service.spec.ts
vendored
@@ -57,36 +57,40 @@ describe("ObjectCacheService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("get", () => {
|
describe("get", () => {
|
||||||
it("should return an observable of the cached object with the specified UUID", () => {
|
it("should return an observable of the cached object with the specified UUID and type", () => {
|
||||||
spyOn(store, 'select').and.returnValue(Observable.of(cacheEntry));
|
spyOn(store, 'select').and.returnValue(Observable.of(cacheEntry));
|
||||||
|
|
||||||
let testObj: any;
|
let testObj: any;
|
||||||
//due to the implementation of spyOn above, this subscribe will be synchronous
|
//due to the implementation of spyOn above, this subscribe will be synchronous
|
||||||
service.get(uuid).take(1).subscribe(o => testObj = o);
|
service.get(uuid, TestClass).take(1).subscribe(o => testObj = o);
|
||||||
expect(testObj.uuid).toBe(uuid);
|
expect(testObj.uuid).toBe(uuid);
|
||||||
expect(testObj.foo).toBe("bar");
|
expect(testObj.foo).toBe("bar");
|
||||||
|
// this only works if testObj is an instance of TestClass
|
||||||
|
expect(testObj.test()).toBe("bar" + uuid);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not return a cached object that has exceeded its time to live", () => {
|
it("should not return a cached object that has exceeded its time to live", () => {
|
||||||
spyOn(store, 'select').and.returnValue(Observable.of(invalidCacheEntry));
|
spyOn(store, 'select').and.returnValue(Observable.of(invalidCacheEntry));
|
||||||
|
|
||||||
let getObsHasFired = false;
|
let getObsHasFired = false;
|
||||||
const subscription = service.get(uuid).subscribe(o => getObsHasFired = true);
|
const subscription = service.get(uuid, TestClass).subscribe(o => getObsHasFired = true);
|
||||||
expect(getObsHasFired).toBe(false);
|
expect(getObsHasFired).toBe(false);
|
||||||
subscription.unsubscribe();
|
subscription.unsubscribe();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getList", () => {
|
describe("getList", () => {
|
||||||
it("should return an observable of the array of cached objects with the specified UUID", () => {
|
it("should return an observable of the array of cached objects with the specified UUID and type", () => {
|
||||||
spyOn(service, 'get').and.returnValue(Observable.of(new TestClass(uuid, "bar")));
|
spyOn(service, 'get').and.returnValue(Observable.of(new TestClass(uuid, "bar")));
|
||||||
|
|
||||||
let testObjs: Array<any>;
|
let testObjs: Array<any>;
|
||||||
service.getList([uuid, uuid]).take(1).subscribe(arr => testObjs = arr);
|
service.getList([uuid, uuid], TestClass).take(1).subscribe(arr => testObjs = arr);
|
||||||
expect(testObjs[0].uuid).toBe(uuid);
|
expect(testObjs[0].uuid).toBe(uuid);
|
||||||
expect(testObjs[0].foo).toBe("bar");
|
expect(testObjs[0].foo).toBe("bar");
|
||||||
|
expect(testObjs[0].test()).toBe("bar" + uuid);
|
||||||
expect(testObjs[1].uuid).toBe(uuid);
|
expect(testObjs[1].uuid).toBe(uuid);
|
||||||
expect(testObjs[1].foo).toBe("bar");
|
expect(testObjs[1].foo).toBe("bar");
|
||||||
|
expect(testObjs[1].test()).toBe("bar" + uuid);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user