Skip to content

Instantly share code, notes, and snippets.

@PillowUnicorn
Created June 22, 2017 23:23
Show Gist options
  • Save PillowUnicorn/5db48d40caef79410f7655a960504157 to your computer and use it in GitHub Desktop.
Save PillowUnicorn/5db48d40caef79410f7655a960504157 to your computer and use it in GitHub Desktop.
Jest test for Redux actions [Template]
import configureStore from 'redux-mock-store'
import * as activityActions from '../activity'
import { mock_activity } from '../../store/mock_data'
const middlewares = []
const mockStore = configureStore( middlewares )
const initialState = {}
const store = mockStore( initialState )
beforeEach( () => {
store.clearActions();
} );
afterEach( () => {
expect( store.getActions() ).toMatchSnapshot();
} )
test( 'Dispatch fetchActivitySucceeded action', () => {
const { status, activity } = mock_activity
store.dispatch( activityActions.fetchActivitySucceeded( status, activity ) );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment