【发布时间】:2015-12-29 21:03:43
【问题描述】:
在 Redux 的 Writing Tests 部分,如果 store.dispatch 字面意思是调用 actions.fetchTodos,store.dispatch(actions.fetchTodos()) 如何不调用 fetch 方法?
it('creates FETCH_TODOS_SUCCESS when fetching todos has been done', (done) => {
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())
})
【问题讨论】:
标签: javascript unit-testing reactjs redux nock