我有一个创建动作的功能
export function dispatchAction (type, payload) {
return dispatch => {
dispatch({type: type, payload: payload})
}
}
我正在为它编写测试
import configureMockStore from 'redux-mock-store'
import thunk from 'redux-thunk'
import * as actions from './actions
const mockStore = configureMockStore([thunk])
const store = mockStore({})
describe('dispatch action', () => {
it('should return action based on type and payload', () => {
const type = 'TEST'
const payload = 'payload'
return store.dispatch(actions.dispatchAction(type, payload)).then(()
=> {
expect(store.getActions())
.toEqual({type, payload})
})
})
})
但我收到Cannot read property 'then' of undefined
。
答案 0 :(得分:1)