vendredi 18 décembre 2020

Assert whether proper methods were called on success and on error of my observable with marbles testing

I am looking to write marbles tests for method which return following observable. I want to make sure that proper methods with proper values are passed through the chain.

  effectGenerator = (myObservable$: Observable<any>) => {
    return myObservable$.pipe(
      switchMap(myObservableValue =>
       myService.makeHttpCall(myObservableValue).pipe(
          tap({
            next: () => {
              method1(myObservableValue);
              method2(myObservableValue + x)
            },
            error: error => hendleError(error)
          })
        )
      )
    );
  };

I would like to assert:

  • If myService where called by proper method and with proper value
  • If on success method1 and method2 where called with proper value
  • If on mySerivce thorw error it was properly handled by my handleError method.

Aucun commentaire:

Enregistrer un commentaire