Angular 6 жасминовых тестов для ngrx / эффектов - PullRequest
0 голосов
/ 18 февраля 2020

Я пытаюсь написать контрольные примеры для эффектов. Может кто-нибудь, пожалуйста, помогите мне, как проверить функцию switchMap внутри него. Заранее спасибо. Вот моя функция

loadMovies$ = createEffect(() => this.actions$.pipe(
    ofType('[Login Page] Login'),
    switchMap(() => this.exampleService.getAll()
      .pipe(
        map(movies => ({ type: '[Movies API] Movies Loaded Success', payload: movies })),
        catchError(() => EMPTY)
      ))
    )
  );

И мое spe c file

it('should return an AddUserSuccess action, with the user, on success', () => {

   actions$ = of({ type: '[Customers Page] Get Customers' });  

    service.getAll();
     effects.loadMovies$.subscribe(action => {
        expect(action).toEqual({
            type: '[Customers API] Get Customers Success',
            payload: [],
        });
    });
  });
...