Created
April 9, 2020 21:51
-
-
Save LarryKarani/2536a85dcdf473b7d7d0bd88cbd7aa82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('post Todos actions', () => { | |
beforeEach(() => { | |
store.clearActions(); | |
}); | |
it('dispatches POST_TODO_SUCCESS after a successfull API requets', () => { | |
mock.onPost('api/todos').reply(201, { response: { item: 'item1' } }) | |
store.dispatch(actions.getTodos()).then(() => { | |
let expectedActions = [ | |
{ type: 'API_REQUEST' }, | |
{ type: 'POST_TODOS_SUCCESS', payload: { item: 'item1' } } | |
] | |
expect(store.getActions()).toEqual(expectedActions) | |
}); | |
}); | |
it('dispatches POST_TODO_FAILURE after a FAILED API requets', () => { | |
mock.onPost('api/todos').reply(400, { error: { message: 'error message' } }); | |
store.dispatch(actions.getTodos()).then(() => { | |
let expectedActions = [ | |
{ type: 'API_REQUEST' }, | |
{ | |
type: 'POST_TODOS_FAIL', | |
payload: { error: { message: 'error message' } } | |
} | |
] | |
expect(store.getActions()).toEqual(expectedActions) | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment