Skip to content

Instantly share code, notes, and snippets.

@sandwichsudo
Last active July 27, 2017 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandwichsudo/1ae272b85c12c91c721df73f29fbcbd3 to your computer and use it in GitHub Desktop.
Save sandwichsudo/1ae272b85c12c91c721df73f29fbcbd3 to your computer and use it in GitHub Desktop.
Add test to update error in state.
// src/containers/RepoSearchPage/reducer/RepoSearchReducer.spec.js
import RepoSearchReducer from './RepoSearchReducer';
import { actionTypes } from '../RepoSearchConstants';
const initialState = {
results: [],
error: '',
};
describe('RepoSearchReducer', () => {
describe('UPDATE_RESULTS', () => {
it('should update the results', () => {
const newState = RepoSearchReducer(initialState, { type: actionTypes.UPDATE_RESULTS, items: ['foo'] });
expect(newState.results).toEqual(['foo']);
});
});
describe('REQUEST_COMPLETE', () => {
it('should update the error', () => {
const newState = RepoSearchReducer(initialState, { type: actionTypes.REQUEST_COMPLETE, error: 'foo' });
expect(newState.error).toEqual('foo');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment