title: How to resolve promise and spy on a function inside axios
body: <pre><code>function getusers(config){
       const {successCB} = config;
       return axios.get(url, params)
        .then(response =&gt; {
          successCB(response.data, config);
        });
  }
  
  ************************ UT ******************************
  
  const mock = new MockAdapter(axios);
  const successCB = jest.fn();
  
  mock.onGet(url).reply(200, 'success');
  const axiosSpy = jest.spyOn(axios, 'get');
  const successCBSpy = jest.spyOn(config, 'successCB');
  
  getUsers({successCB});
  </code></pre>
  
  <p>axiosSpy is success from below code</p>
  
  <pre><code>expect(axiosSpy).toHaveBeenCalled();
  </code></pre>
  
  <p>But it's not reaching inside to resolve with results for successCB </p>
  
  <pre><code>expect(successCBSpy).toHaveBeenCalled();
  </code></pre>
  
  <p>Throwing error as: <code>successCB</code> never called</p>
  
  <p>What am I doing wrong and what should I expect here?</p>
  
  <p>I am only able to use ES6 solutions only.</p>