0

I am looking for a way to test the functions passed as props to a React Bootstrap modal in React Redux, generated in a similar way to here: https://stackoverflow.com/a/35641680/4401847.

I need to test functions passed as props through mapDispatchToProps/mergeProps with Chai and Mocha. The way I'm trying to do so is by dispatching actions which make the modal pop up

This would be an example of a test case, at least its first lines:

it("should dispatch an action when clicking a button", function (done) {
   store.dispatch({
       type: "modal/show",
       modalType: "POST",
       modalProps: {
           mode: "add",
           title "Create new post"
       }
   }); 
   const modal = mount(<Provider store={store}><PostModal/><Provider/>);
   setTimeOut(function() {
       //I don't know how to access the functions passed as props via dispatchToProps and mergeProps.
   });
});

Thank you very much

Community
  • 1
  • 1
Gothbag
  • 11
  • 7
  • 1
    I'm airing on the side that you don't do that. You can test the function in isolation due to the fact that redux actions are pure functions.... – Callum Linington Feb 06 '17 at 13:28
  • The thing is that I'm running coverage tests and I'm failing to surpass the 80% mark because of functions passed as props using the mapDispatchToProps and mergeProps functions. – Gothbag Feb 06 '17 at 16:02
  • Just mock them out... coverage isn't everything.... – Callum Linington Feb 06 '17 at 16:19

0 Answers0