update api.js api client, and axios mock, and add api.js unit tests

This commit is contained in:
John Mitchell
2018-10-24 16:52:11 -04:00
parent 22112f3dd8
commit 0373058540
3 changed files with 147 additions and 2 deletions

21
__mocks__/axios.js Normal file
View File

@@ -0,0 +1,21 @@
const axios = require('axios');
jest.genMockFromModule('axios');
axios.create = jest.fn(() => axios);
axios.get = jest.fn(() => axios);
axios.post = jest.fn(() => axios);
axios.create.mockReturnValue({
get: axios.get,
post: axios.post
});
axios.get.mockResolvedValue('get results');
axios.post.mockResolvedValue('post results');
axios.customClearMocks = () => {
axios.create.mockClear();
axios.get.mockClear();
axios.post.mockClear();
};
module.exports = axios;