Skip to content

Instantly share code, notes, and snippets.

@tiagogomes772
Created October 23, 2018 08:03
Show Gist options
  • Save tiagogomes772/5ca419f44d100616909c64c62c251cdd to your computer and use it in GitHub Desktop.
Save tiagogomes772/5ca419f44d100616909c64c62c251cdd to your computer and use it in GitHub Desktop.
import Reducer from './Reducer';
describe('reducer', () => {
it('should handle the Action REQUEST_ADVICE', () => {
expect(
Reducer(
{
fetching: false,
randomAdvice: null,
},
{
type: 'REQUEST_ADVICE',
},
),
).toEqual({
fetching: true,
randomAdvice: null,
});
});
it('should handle the Action RESPONSE_ADVICE_FAILURE', () => {
expect(
Reducer(
{
fetching: true,
},
{
type: 'RESPONSE_ADVICE_FAILURE',
},
),
).toEqual({
fetching: false,
});
});
it('should handle the Action RESPONSE_ADVICE_SUCCESS', () => {
expect(
Reducer(
{
fetching: false,
randomAdvice: null,
},
{
type: 'RESPONSE_ADVICE_SUCCESS',
payload: 'Random advice inserted',
},
),
).toEqual({
fetching: false,
randomAdvice: 'Random advice inserted',
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment