How to unit test whether an action was dispatched?
For example, in a LogoutService, I have this simple method:
logout(username: string) {
store.dis
I tried this approach to test if both actions were called:
3. Test if actions are being called
// ...
it('should call actions ResetStateAction and LogoutAction', async( () => {
let actionDispatched = false;
zip(
actions$.pipe(ofActionDispatched(ResetStateAction)),
actions$.pipe(ofActionDispatched(LogoutAction))
)
.subscribe( () => actionDispatched = true );
store.dispatch([new ResetStateAction(), new LogoutAction()])
.subscribe(
() => expect(actionDispatched).toBe(true)
);
}));
// ...