mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 20:00:43 -03:30
- Move API GET request to /v2/config out to the top level of our App. - Store /v2/config response data in sessionStorage. - Use Context API to pass down relevant data to Organizations component. - Wrap our AnsibleSelect component as a context consumer and pass in the list of Ansible Environments of the logged in user. - Clear sessionStorage object when user logs out. - Update unit tests.
39 lines
852 B
JavaScript
39 lines
852 B
JavaScript
import * as endpoints from '../src/endpoints';
|
|
|
|
const axios = require('axios');
|
|
const mockAPIConfigData = {
|
|
data: {
|
|
custom_virtualenvs: ['foo', 'bar'],
|
|
ansible_version: "2.7.2",
|
|
version: "2.1.1-40-g2758a3848"
|
|
}
|
|
};
|
|
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.mockImplementation((endpoint) => {
|
|
if (endpoint === endpoints.API_CONFIG) {
|
|
return new Promise((resolve, reject) => {
|
|
resolve(mockAPIConfigData);
|
|
});
|
|
}
|
|
else {
|
|
return 'get results';
|
|
}
|
|
});
|
|
axios.post.mockResolvedValue('post results');
|
|
|
|
axios.customClearMocks = () => {
|
|
axios.create.mockClear();
|
|
axios.get.mockClear();
|
|
axios.post.mockClear();
|
|
};
|
|
|
|
module.exports = axios;
|