I am using EMPTY from rxjs in order to handle the catchError, What is the correct value for expected in order to pass the fail scenario.
import { Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { EMPTY } from 'rxjs';
import { map, mergeMap, catchError } from 'rxjs/operators';
import { MoviesService } from './movies.service';
@Injectable()
export class MovieEffects {
loadMovies$ = createEffect(() => this.actions$.pipe(
ofType('[Movies Page] Load Movies'),
mergeMap(() => this.moviesService.getAll()
.pipe(
map(movies => ({ type: '[Movies API] Movies Loaded Success', payload: movies })),
catchError(() => EMPTY)
))
)
);
constructor(
private actions$: Actions,
private moviesService: MoviesService
) {}
}
// unit test
it('should return a empty observable', () => {
this.moviesServiceSpy.and.return(throwError('Error in service'));
action$ = hot('a', a: { loadMovies() });
const expected = cold('|');
expect(loadMovies$).toBeObservable(expected);
})