function getusers(config){
const {successCB} = config;
return axios.get(url, params)
.then(response => {
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});
axiosSpy is success from below code
expect(axiosSpy).toHaveBeenCalled();
But it's not reaching inside to resolve with results for successCB
expect(successCBSpy).toHaveBeenCalled();
Throwing error as: successCB
never called
What am I doing wrong and what should I expect here?
I am only able to use ES6 solutions only.