mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
move effect for cleaning cache to auth.effects
This commit is contained in:
@@ -35,6 +35,7 @@ import { EPersonMock } from '../../shared/testing/eperson.mock';
|
||||
import { AppState, storeModuleConfig } from '../../app.reducer';
|
||||
import { StoreActionTypes } from '../../store.actions';
|
||||
import { isAuthenticated, isAuthenticatedLoaded } from './selectors';
|
||||
import { AuthorizationDataService } from '../data/feature-authorization/authorization-data.service';
|
||||
|
||||
describe('AuthEffects', () => {
|
||||
let authEffects: AuthEffects;
|
||||
@@ -44,6 +45,8 @@ describe('AuthEffects', () => {
|
||||
let token;
|
||||
let store: MockStore<AppState>;
|
||||
|
||||
const authorizationService = jasmine.createSpyObj(['invalidateAuthorizationsRequestCache']);
|
||||
|
||||
function init() {
|
||||
authServiceStub = new AuthServiceStub();
|
||||
token = authServiceStub.getToken();
|
||||
@@ -68,6 +71,7 @@ describe('AuthEffects', () => {
|
||||
providers: [
|
||||
AuthEffects,
|
||||
provideMockStore({ initialState }),
|
||||
{ provide: AuthorizationDataService, useValue: authorizationService },
|
||||
{ provide: AuthService, useValue: authServiceStub },
|
||||
provideMockActions(() => actions),
|
||||
// other providers
|
||||
@@ -417,4 +421,16 @@ describe('AuthEffects', () => {
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('invalidateAuthorizationsRequestCache$', () => {
|
||||
it('should call invalidateAuthorizationsRequestCache method in response to a REHYDRATE action', (done) => {
|
||||
actions = hot('--a-|', { a: { type: StoreActionTypes.REHYDRATE } });
|
||||
|
||||
authEffects.invalidateAuthorizationsRequestCache$.subscribe(() => {
|
||||
expect((authEffects as any).authorizationsService.invalidateAuthorizationsRequestCache).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user