mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
87968: Fix unit tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { fakeAsync, flush, TestBed } from '@angular/core/testing';
|
||||
import { fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||
|
||||
import { provideMockActions } from '@ngrx/effects/testing';
|
||||
import { Store, StoreModule } from '@ngrx/store';
|
||||
@@ -396,44 +396,43 @@ describe('AuthEffects', () => {
|
||||
});
|
||||
|
||||
describe('when auth loaded is false', () => {
|
||||
it('should not call removeToken method', (done) => {
|
||||
it('should not call removeToken method', fakeAsync(() => {
|
||||
store.overrideSelector(isAuthenticatedLoaded, false);
|
||||
actions = hot('--a-|', { a: { type: StoreActionTypes.REHYDRATE } });
|
||||
actions = observableOf({ type: StoreActionTypes.REHYDRATE });
|
||||
spyOn(authServiceStub, 'removeToken');
|
||||
|
||||
authEffects.clearInvalidTokenOnRehydrate$.subscribe(() => {
|
||||
expect(authServiceStub.removeToken).not.toHaveBeenCalled();
|
||||
|
||||
expect(false).toBeTrue(); // subscribe to trigger taps, fail if the effect emits (we don't expect it to)
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
tick(1000);
|
||||
expect(authServiceStub.removeToken).not.toHaveBeenCalled();
|
||||
}));
|
||||
});
|
||||
|
||||
describe('when auth loaded is true', () => {
|
||||
it('should call removeToken method', fakeAsync(() => {
|
||||
it('should call removeToken method', (done) => {
|
||||
spyOn(console, 'log').and.callThrough();
|
||||
|
||||
store.overrideSelector(isAuthenticatedLoaded, true);
|
||||
actions = hot('--a-|', { a: { type: StoreActionTypes.REHYDRATE } });
|
||||
actions = observableOf({ type: StoreActionTypes.REHYDRATE });
|
||||
spyOn(authServiceStub, 'removeToken');
|
||||
|
||||
authEffects.clearInvalidTokenOnRehydrate$.subscribe(() => {
|
||||
expect(authServiceStub.removeToken).toHaveBeenCalled();
|
||||
flush();
|
||||
done();
|
||||
});
|
||||
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('invalidateAuthorizationsRequestCache$', () => {
|
||||
it('should call invalidateAuthorizationsRequestCache method in response to a REHYDRATE action', (done) => {
|
||||
actions = hot('--a-|', { a: { type: StoreActionTypes.REHYDRATE } });
|
||||
actions = observableOf({ type: StoreActionTypes.REHYDRATE });
|
||||
|
||||
authEffects.invalidateAuthorizationsRequestCache$.subscribe(() => {
|
||||
expect((authEffects as any).authorizationsService.invalidateAuthorizationsRequestCache).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -25,9 +25,11 @@ describe('Notifications reducer', () => {
|
||||
beforeEach(async () => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [NotificationComponent, NotificationsBoardComponent],
|
||||
providers: [NotificationsService],
|
||||
imports: [
|
||||
providers: [
|
||||
NotificationsService,
|
||||
ChangeDetectorRef,
|
||||
],
|
||||
imports: [
|
||||
StoreModule.forRoot({ notificationsReducer }, storeModuleConfig),
|
||||
]
|
||||
});
|
||||
|
Reference in New Issue
Block a user