Skip to content

Instantly share code, notes, and snippets.

@acr13
Created June 7, 2017 02:27
Show Gist options
  • Save acr13/ae42cfb95bb01c5630cd2eac6acd7293 to your computer and use it in GitHub Desktop.
Save acr13/ae42cfb95bb01c5630cd2eac6acd7293 to your computer and use it in GitHub Desktop.
Simple Saga Test
import { call, put } from 'redux-saga/effects';
import { API_BUTTON_CLICK_SUCCESS, } from './actions/consts';
import { getDataFromAPI } from './api';
it('apiSideEffect - fetches data from API and dispatches a success action', () => {
const generator = apiSideEffect();
expect(generator.next().value)
.toEqual(call(getDataFromAPI));
expect(generator.next().value)
.toEqual(put({ type: API_BUTTON_CLICK_SUCCESS }));
expect(generator.next())
.toEqual({ done: true, value: undefined });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment