mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 23:13:04 +00:00
updated angular/rxjs to v6 successfully
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import { ResponseCacheService } from './response-cache.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { CoreState } from '../core.reducers';
|
||||
import { RestResponse } from './response-cache.models';
|
||||
import { ResponseCacheEntry } from './response-cache.reducer';
|
||||
import { first } from 'rxjs/operators';
|
||||
|
||||
describe('ResponseCacheService', () => {
|
||||
let service: ResponseCacheService;
|
||||
@@ -41,11 +42,11 @@ describe('ResponseCacheService', () => {
|
||||
describe('get', () => {
|
||||
it('should return an observable of the cached request with the specified key', () => {
|
||||
spyOn(store, 'select').and.callFake((...args: any[]) => {
|
||||
return Observable.of(validCacheEntry(keys[1]));
|
||||
return observableOf(validCacheEntry(keys[1]));
|
||||
});
|
||||
|
||||
let testObj: ResponseCacheEntry;
|
||||
service.get(keys[1]).first().subscribe((entry) => {
|
||||
service.get(keys[1]).pipe(first()).subscribe((entry) => {
|
||||
testObj = entry;
|
||||
});
|
||||
expect(testObj.key).toEqual(keys[1]);
|
||||
@@ -53,7 +54,7 @@ describe('ResponseCacheService', () => {
|
||||
|
||||
it('should not return a cached request that has exceeded its time to live', () => {
|
||||
spyOn(store, 'select').and.callFake((...args: any[]) => {
|
||||
return Observable.of(invalidCacheEntry(keys[1]));
|
||||
return observableOf(invalidCacheEntry(keys[1]));
|
||||
});
|
||||
|
||||
let getObsHasFired = false;
|
||||
@@ -65,17 +66,17 @@ describe('ResponseCacheService', () => {
|
||||
|
||||
describe('has', () => {
|
||||
it('should return true if the request with the supplied key is cached and still valid', () => {
|
||||
spyOn(store, 'select').and.returnValue(Observable.of(validCacheEntry(keys[1])));
|
||||
spyOn(store, 'select').and.returnValue(observableOf(validCacheEntry(keys[1])));
|
||||
expect(service.has(keys[1])).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if the request with the supplied key isn\'t cached', () => {
|
||||
spyOn(store, 'select').and.returnValue(Observable.of(undefined));
|
||||
spyOn(store, 'select').and.returnValue(observableOf(undefined));
|
||||
expect(service.has(keys[1])).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false if the request with the supplied key is cached but has exceeded its time to live', () => {
|
||||
spyOn(store, 'select').and.returnValue(Observable.of(invalidCacheEntry(keys[1])));
|
||||
spyOn(store, 'select').and.returnValue(observableOf(invalidCacheEntry(keys[1])));
|
||||
expect(service.has(keys[1])).toBe(false);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user