mardi 29 décembre 2015

What is the purpose of Redux Async Action Testing?

Could someone explain why we test asynchronous actions? What are we hoping to ensure works?

So in the docs, http://ift.tt/1WuLEat, we mock the server request.

nock('http://example.com/')
  .get('/todos')
  .reply(200, { todos: ['do something'] })

const expectedActions = [
  { type: types.FETCH_TODOS_REQUEST },
  { type: types.FETCH_TODOS_SUCCESS, body: { todos: ['do something']  } }
]
const store = mockStore({ todos: [] }, expectedActions, done)
store.dispatch(actions.fetchTodos())

So we aren't testing to see if we contact the server. We are testing to see if the correct sequence of actions takes place, given a response of 200 correct?

Aucun commentaire:

Enregistrer un commentaire