title: How to unit test mapDispatchToProps with thunk action
body: <p>I have the following Redux action creator:</p>
  
  <pre><code>export const keyDown = key =&gt; (dispatch, getState) =&gt; {
      const { modifier } = getState().data;
      dispatch({ type: KEYDOWN, key });
      return handle(modifier, key); // Returns true or false
  };
  </code></pre>
  
  <p>And the following connected component:</p>
  
  <pre><code>export const mapDispatchToProps = dispatch =&gt; ({
      onKeyDown: e =&gt; {
          if(e.target.tagName === "INPUT") return;
          const handledKey = dispatch(keyDown(e.keyCode));
          if(handledKey) {
              e.preventDefault();
          }
      }
  });
  </code></pre>
  
  <p>I am trying to write a test to ensure that <code>dispatch</code> is called with the <code>keyDown</code> action when the <code>tagName</code> is anything other than <code>"INPUT"</code>. This is my test:</p>
  
  <pre><code>import { spy } from "sinon";
  import keycode from "keycodes";
  import { mapDispatchToProps } from "./connected-component";
  import { keyDown } from "./actions";
  
  // Creates a simple Event stub...
  const createEvent = (tag, keyCode) =&gt; ({
      target: {
          tagName: tag.toUpperCase()
      },
      preventDefault: spy(),
      keyCode
  });
  
  it("Dispatches a keyDown event with the specified keyCode if the selected element is not an &lt;input&gt;", () =&gt; {
      const dispatch = spy();
      const keyCode = keycode("u");
      mapDispatchToProps(dispatch).onKeyDown(createEvent("div", keyCode));
      // This fails...
      expect(dispatch).to.have.been.calledWith(keyDown(keycode));
  });
  </code></pre>
  
  <p>Presumably this is something to do with using arrow functions? Is there any way I can ensure that dispatch was called with the function signature that I expect?</p>