test fixup

This commit is contained in:
Jake McDermott
2019-01-02 02:28:24 -05:00
parent 8f4437e17e
commit 31d0347553
7 changed files with 108 additions and 141 deletions

View File

@@ -1,38 +0,0 @@
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;