title: Mock-testing the catch block of a promise method
body: <p>My method is:</p>
  <pre><code>getFilterData(filterFields, comparisons, filterValues) {
      return new Promise((resolve) =&gt; {
        axios.post('/projects/filter', {
          filter_fields: filterFields,
          comparisons,
          filter_values: filterValues,
        })
          .then((response) =&gt; {
            this.setState({
              projectData: response.data,
              isFilterModalOpen: false,
            }, resolve(response));
          })
          .catch(this.handleRequestError);
      });
    }
  </code></pre>
  <p>I tried writing a test:</p>
  <pre><code>describe('When getFilterData() is unsuccessful', () =&gt; {
    it('calls handleRequestError', async () =&gt; {
        axios.post.mockImplementation(() =&gt; Promise.reject(HREResponse));
        const app = await global.shallowWithIntl(&lt;ManageProjectsPage /&gt;).dive();
        const spy = jest.spyOn(app.instance(), 'handleRequestError');
        await app.instance().getFilterData(['language'], ['='], ['Java'])
          .catch(error =&gt; expect(error).toBe(HREResponse));
        console.log(app.instance().state);
        app.update();
        expect(spy).toHaveBeenCalled();
        spy.mockRestore();
       });
       axios.post.mockReset();
     }); 
  </code></pre>
  <p>The error says, expected mock function to have been called, but it was not called.
  More details:</p>
  <ol>
  <li>The filter is defined as a post method.</li>
  <li>HREResponse has status 504, which is the status handleRequestError receives.</li>
  </ol>