I have this one effect where some preconditions have to be true so that a specific action gets dispatched:
@Effect()
prepareLoadDetails$: Observable<Action> = this.actions$
.ofType(PREPARE_LOAD_DETAILS)
.withLatestFrom(this.store)
.filter(([actionType, stateStore]) => this.necessarySelectionsMade(stateStore))
.map(() => {
return new LoadDetailsAction();
});
Now I'm somehow stuck in unit testing this code. There's no problem getting the LoadDetailsAction dispatched. But how can I test that no action is dispatched in the other cases?
describe('prepareLoadDetails$', () => {
it('should trigger a LoadDetailsAction if all needed selections are made', (done) => {
// given
const {runner, effects} = setup({
// some setup of state here
});
// when
runner.queue(new PrepareLoadDetailsAction());
// then
effects.prepareLoadDetails$.subscribe(result => {
expect(result).toEqual(new LoadDetailsAction());
done();
});
});
it('should not trigger a LoadDetailsAction if needed selections are not made', (done) => {
// given
const {runner, effects} = setup({
// some other setup of state here
});
// when
runner.queue(new PrepareLoadDetailsAction());
// then ???
});
});