我正在尝试为效果编写测试用例。任何人都可以帮助我如何测试其中的 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)
))
)
);
还有我的规格文件
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: [],
});
});
});