August 2017
Beginner
374 pages
10h 41m
English
The first test will be the success case—we are going to mock the API and then call the fetchUser action creator. Afterwards, we check if the FETCH_USER_REQUEST and FETCH_USER_SUCCESS actions were dispatched to our mock store:
test('dispatches FETCH_USER_SUCCESS when fetching succeeds', () => {
const username = 'dan' const realname = 'Daniel Bugl' const userObj = { username, realname } nock('http://localhost:8080/') .get(`/api/users/${username}`) .reply(200, userObj)
Read now
Unlock full access