bigbuffet-rw/app/soapbox/__mocks__/api.js
2020-06-09 17:16:22 -05:00

18 lines
412 B
JavaScript

import MockAdapter from 'axios-mock-adapter';
const api = jest.requireActual('../api').default;
let mocks = [];
export const __stub = func => mocks.push(func);
export const __clear = () => mocks = [];
const setupMock = axios => {
const mock = new MockAdapter(axios);
mocks.map(func => func(mock));
};
export default (...params) => {
const axios = api(...params);
setupMock(axios);
return axios;
};