| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- /* eslint-disable prefer-reflect */
- import { testSaga } from 'redux-saga-test-plan';
- import {
- annoySaga
- } from 'sagas/annoy';
- import {
- apiRequest
- } from 'sagas/api';
- import {
- ANNOYED
- } from 'constants/actions';
- import {
- annoyResponded
- } from 'actions/annoy';
- describe('Annoy saga', () => {
- it('should listen to ANNOYED and send an API request', () => {
- testSaga(annoySaga)
- .next()
- .take(ANNOYED)
- .next()
- .call(apiRequest, 'post', 'annoy')
- .next({ err: null, response: { isResponse: true } })
- .put(annoyResponded(null))
- .next()
- .take(ANNOYED);
- const err = new Error('something bad happened');
- testSaga(annoySaga)
- .next()
- .take(ANNOYED)
- .next()
- .call(apiRequest, 'post', 'annoy')
- .next({ err, response: null })
- .put(annoyResponded(err))
- .next()
- .take(ANNOYED);
- });
- });
|