import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as CommonActions from 'common/actions/common.actions';
import Activity from './activity.component';
const mapStateToProps = ({ common }) => ({common});
const mapDispatchToProps = dispatch => bindActionCreators(
{
getNationalities: CommonActions.getNationalities,
},dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(Activity);
如何测试这样的包含mapStateToProps
,mapDispatchToProps
和connect
的容器组件?
答案 0 :(得分:1)
React-test-render可以测试组件,您必须导入包含mapStateToProps
,mapDispatchToProps
的组件。
示例:
<YourComponentName
common={jest.fn()}
getNationalities={jest.fn()}
/>