How do I test an effect that returns multiple actions

Discussão em 'Angular' iniciado por Lev, Dezembro 17, 2024.

  1. Lev

    Lev Guest

    I have an effect that returns action A then action B

    @Effect() myEffect$: Observable <Action> = this.actions$
    .ofType('MY_ACTION')
    .switchMap(() => Observable.of(
    // subscribers will be notified
    { type: 'ACTION_ONE' },
    // subscribers will be notified (again ...)
    { type: 'ACTION_TWO' }
    ));


    How can I test the two successive returned actions ?

    it('should return action one then action two', () => {
    runner.queue(new myAction());
    const expectedResult = twoSuccesiveActions;
    sessionEffect.myEffect$.subscribe(result => {
    // how do I test those two succesively returned actions
    expect(result).toEqual(expectedResult);
    });
    });

    Continue reading...

Compartilhe esta Página