mirror of
https://github.com/ansible/awx.git
synced 2026-02-16 10:40:01 -03:30
update api.js api client, and axios mock, and add api.js unit tests
This commit is contained in:
21
__mocks__/axios.js
Normal file
21
__mocks__/axios.js
Normal 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;
|
||||
Reference in New Issue
Block a user