import axios from 'axios';
import { API_ROOT } from './api.config';
const baseAPI = axios.create({
baseURL: API_ROOT
});
export default (method, url, payload, config = {}) => {
switch (method.toLowerCase()) {
case 'get':
case 'head':
case 'delete':
case 'options':
return baseAPI[method](url, config);
case 'post':
case 'put':
case 'patch':
return baseAPI[method](url, payload, config);
default:
throw new Error('CMS: Http method not specified!');
}
};
Tests work fine for get, delete, post and put, but fail for head, options and patch because jest-mock-axios doesn't seem to support them. I realize they're rarely used nowadays, but is it possible to add support for the sake of completeness?
Testing the following code:
Tests work fine for get, delete, post and put, but fail for head, options and patch because jest-mock-axios doesn't seem to support them. I realize they're rarely used nowadays, but is it possible to add support for the sake of completeness?