Skip to content

Instantly share code, notes, and snippets.

@PillowUnicorn
Created June 22, 2017 23:27
Show Gist options
  • Save PillowUnicorn/fceb17e87ba31f2977294f5ce42bdc00 to your computer and use it in GitHub Desktop.
Save PillowUnicorn/fceb17e87ba31f2977294f5ce42bdc00 to your computer and use it in GitHub Desktop.
Jest test for Redux Reducers [Template]
import configureStore from 'redux-mock-store'
import * as errorsActions from '../../../actions/errors'
import { mock_errors } from '../../../store/mock_data'
import setErrorMessage from '../set_error_message'
import resetErrorMessage from '../reset_error_message'
const middlewares = []
const mockStore = configureStore( middlewares )
const initialState = {}
const store = mockStore( initialState )
beforeEach( () => {
store.clearActions();
} );
test( 'Select setErrorMessage reducer', () => {
const { key, message } = mock_errors
const action = errorsActions.setErrorMessage( key, message )
expect( setErrorMessage( undefined, action ) ).toMatchSnapshot();
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment