Skip to content

Instantly share code, notes, and snippets.

@charisschomba
Created February 20, 2019 10:08
Show Gist options
  • Save charisschomba/8cc019739427dc761ebaac66b64a42e8 to your computer and use it in GitHub Desktop.
Save charisschomba/8cc019739427dc761ebaac66b64a42e8 to your computer and use it in GitHub Desktop.
import {
REGISTER_USER,
REGISTER_SUCCESS,
REGISTER_ERROR,
} from '../../../constants/users';
import addUser from '../../../store/reducers/users';
import initialState, {
initialStateEdit,
} from '../../../__mocks__/initialState';
const action = { payload: {} };
describe('User Reducer test', () => {
it('should return initial state when there is no action', () => {
expect(addUser(initialState, action)).toEqual(initialState);
});
it('should handle EDIT_USER', () => {
action.type = REGISTER_USER;
expect(addUser(initialState, action).success).toEqual(false);
});
it('should handle USER_EDIT_SUCCESS', () => {
action.type = REGISTER_SUCCESS;
expect(addUser(initialStateEdit, action).success).toEqual(true);
});
it('should handle USER_EDIT_ERROR', () => {
action.type = REGISTER_ERROR;
expect(addUser(initialStateEdit, action).success).toEqual(false);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment