diff --git a/src/app/core/auth/auth.effects.spec.ts b/src/app/core/auth/auth.effects.spec.ts index ff3873beef..f09db04d99 100644 --- a/src/app/core/auth/auth.effects.spec.ts +++ b/src/app/core/auth/auth.effects.spec.ts @@ -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(); }); }); }); diff --git a/src/app/shared/notifications/notifications.reducers.spec.ts b/src/app/shared/notifications/notifications.reducers.spec.ts index 2b93e9bf94..b834797115 100644 --- a/src/app/shared/notifications/notifications.reducers.spec.ts +++ b/src/app/shared/notifications/notifications.reducers.spec.ts @@ -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), ] });