In an integration test I want to test that a connected action creator gets called.
describe('SomeContainer', () => {
let subject, store, fancyActionCreator
beforeEach(() => {
store = createStore(combineReducers({ /* ... */ }))
fancyActionCreator = sinon.spy()
const props = {
fancyActionCreator
}
subject = (
<Provider store={store}>
<SomeContainer {...props} />
</Provider>
)
})
it('calls fancyActionCreator on mount', () => {
mount(subject)
expect(fancyActionCreator.callCount).to.equal(1)
})
}
The action creator is called inside componentWillMount and works as expected beyond the test environment.
The problem is that the original action creator gets called in the test and does not get mocked away properly.
I've the feeling it's because of Redux's connect() method that is replacing the spy:
connect(mapStateToProps, { fancyActionCreator })(SomeContainer)
Aucun commentaire:
Enregistrer un commentaire