all files / src/ wrapMapDispatchToProps.js

100% Statements 22/22
100% Branches 10/10
100% Functions 6/6
100% Lines 10/10
6 statements, 1 function, 3 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32   58×                               55×              
import {bindActionCreators} from 'redux';
 
const wrapMapDispatchToProps = (mapDispatchToProps, actionCreators) => {
  if (mapDispatchToProps) {
    if (typeof mapDispatchToProps === 'function') {
      if (mapDispatchToProps.length > 1) {
        return (dispatch, ownProps) => ({
          dispatch,
          ...mapDispatchToProps(dispatch, ownProps),
          ...bindActionCreators(actionCreators, dispatch)
        });
      }
      return dispatch => ({
        dispatch,
        ...mapDispatchToProps(dispatch),
        ...bindActionCreators(actionCreators, dispatch)
      });
    }
    return dispatch => ({
      dispatch,
      ...bindActionCreators(mapDispatchToProps, dispatch),
      ...bindActionCreators(actionCreators, dispatch)
    });
  }
  return dispatch => ({
    dispatch,
    ...bindActionCreators(actionCreators, dispatch)
  });
};
 
export default wrapMapDispatchToProps;