annoy.spec.js 1015 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* eslint-disable prefer-reflect */
  2. import { testSaga } from 'redux-saga-test-plan';
  3. import {
  4. annoySaga
  5. } from 'sagas/annoy';
  6. import {
  7. apiRequest
  8. } from 'sagas/api';
  9. import {
  10. ANNOYED
  11. } from 'constants/actions';
  12. import {
  13. annoyResponded
  14. } from 'actions/annoy';
  15. describe('Annoy saga', () => {
  16. it('should listen to ANNOYED and send an API request', () => {
  17. testSaga(annoySaga)
  18. .next()
  19. .take(ANNOYED)
  20. .next()
  21. .call(apiRequest, 'post', 'annoy')
  22. .next({ err: null, response: { isResponse: true } })
  23. .put(annoyResponded(null))
  24. .next()
  25. .take(ANNOYED);
  26. const err = new Error('something bad happened');
  27. testSaga(annoySaga)
  28. .next()
  29. .take(ANNOYED)
  30. .next()
  31. .call(apiRequest, 'post', 'annoy')
  32. .next({ err, response: null })
  33. .put(annoyResponded(err))
  34. .next()
  35. .take(ANNOYED);
  36. });
  37. });