Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should use provided flattening operator', () => {
const sources$ = hot(' -a--b', genActions('ab'));
const project = () => cold('v------(w|)', genActions('vw'));
const error = () => createAction('e')();
// Merge map starts project streams in parallel
const expected$ = cold('-v--v---w--w', genActions('vw'));
const output$ = sources$.pipe(act({ project, error, operator: mergeMap }));
expect(output$).toBeObservable(expected$);
});
it('should flatten projects with concatMap by default', () => {
const sources$ = hot(' -a--b', genActions('ab'));
const project = () => cold('v------(w|)', genActions('vw'));
const error = () => createAction('e')();
// Even thought source produced actions one right after another, operator
// wait for the project to complete before handling second source action.
const expected$ = cold('-v------(wv)---w', genActions('vw'));
const output$ = sources$.pipe(act(project, error));
expect(output$).toBeObservable(expected$);
});
it('should call project functon', () => {
const sources$ = hot('-a-b', genActions('ab'));
const actual$ = new Subject();
const project = jasmine
.createSpy('project')
.and.callFake((...args: [Action, number]) => {
actual$.next(args);
return cold('(v|)', genActions('v'));
});
const error = () => createAction('e')();
sources$.pipe(act(project, error)).subscribe();
expect(actual$).toBeObservable(
cold(' -a-b', {
a: [createAction('a')(), 0],
b: [createAction('b')(), 1],
})
);
});