mirror of
https://github.com/ansible/awx.git
synced 2026-10-31 14:36:17 -02:30
update api.js api client, and axios mock, and add api.js unit tests
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user