mirror of
https://github.com/ansible/awx.git
synced 2026-02-14 17:50:02 -03:30
Implement React Context API
- 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.
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
const axios = require('axios');
|
||||
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);
|
||||
@@ -9,7 +17,16 @@ axios.create.mockReturnValue({
|
||||
get: axios.get,
|
||||
post: axios.post
|
||||
});
|
||||
axios.get.mockResolvedValue('get results');
|
||||
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 = () => {
|
||||
|
||||
Reference in New Issue
Block a user