Closed Shyam-Chen closed 6 years ago
// decrementAsync.js import { of } from 'rxjs'; import { delay, filter } from 'rxjs/operators'; export const decrementAsync = ({ dispatch }) => { of(null) .pipe(delay(1000)) .subscribe(() => dispatch('decrement')); // It can not be tested };
// decrementAsync.spec.js import { marbles } from 'rxjs-marbles/jest'; import { decrementAsync } from './decrementAsync'; describe('decrementAsync', () => { it('should handle decrementAsync', marbles((m) => { const dispatch = (type) => { const source = m.hot('--^-a-----|', { a: null }); const subs = '^-------!'; const expected = '---a----|'; const destination = source.pipe(delay(m.time('-|'))); m.expect(destination).toBeObservable(expected); m.expect(source).toHaveSubscriptions(subs); m.expect(type).toBe('decrement'); }; decrementAsync({ dispatch }); })); });
Please read this part of the README.