How to write unit test so that mapDispatchToProps correctly returns action creators that were wrapped in a dispatch function?
I am currently using Mocha and Enzyme for testing.
Here is my container component.
import { Component } from 'react'
import { connect } from 'react-redux'
import Sidebar from '/components/Sidebar'
import Map from '/components/Map'
import * as LayerActions from '../actions/index'
// Use named export for unconnected component (for tests)
export const App = ({layers, actions} ) => (
<div>
<Sidebar LayerActions={actions} />
<Map />
</div>
)
export const mapStateToProps = state => ({
layers: state.layers
})
export const mapDispatchToProps = dispatch => ({
actions: bindActionCreators(LayerActions, dispatch)
})
// Use default export for the connected component (for app)
export default connect(mapStateToProps, mapDispatchToProps)(App)
source
share