title: Jest: Cannot read property then of undefined
body: <p>I have situation in my unit test case for a react application, where in a function calls for another function received in props from parent component. The parent component functions definition is something like this:</p>
  
  <pre><code>onSavePropClick(action) { 
      const save = this.saveProperty(action);
      if(action === SAVE){
          return () =&gt; new Promise(() =&gt; {
              resolve(this.calculate().then(save));
         });
      }
  return save;
  }
  </code></pre>
  
  <p>This function call has been passed as props to the child component as</p>
  
  <pre><code>&lt;MyComponent finalSave={this.onSavePropClick(SAVE)} onClose={()=&gt;this.setState({closeWindow: true})} /&gt;
  </code></pre>
  
  <p>MyComponent has a function:</p>
  
  <pre><code>savingAndShowResults() {
  const { finalSave, onClose } = this.props;
  finalSave().then(() =&gt; {
  onClose();
  });
  return true;
  }
  </code></pre>
  
  <p>Now when I have a test for the  executed, it throws me error as  “Cannot read property then of undefined”, the test is as follows</p>
  
  <pre><code>const initialProps={
  finalSave: jest.fn(),
  onClose: jest.fn()
  };
  
  it(‘should handle saving and show results’, () =&gt; {
  const component = shallow(
  &lt;MyComponent {...initialProps} /&gt;
  );
  component.instance().savingAndShowResults();
  expect(initialProps.finalSave).toHaveBeenCalled();
  expect(initialProps.onClose).toHaveBeenCalled();
  });
  </code></pre>
  
  <p>I am not able to figure out why even on resolving in return in promise of Parent component’s function, gives me this error.
  Please suggest.</p>