bigbuffet-rw/app/soapbox/__mocks__/api.js

19 lines
412 B
JavaScript
Raw Normal View History

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