Sha256: 028a079f457ab958f70351c0700c12e5b7c30b691499e538508e24d72551f223
Contents?: true
Size: 727 Bytes
Versions: 52
Compression:
Stored size: 727 Bytes
Contents
import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; // TODO: figure out way to reuse this from foreman export const mock = new MockAdapter(axios); const methods = { GET: 'onGet', POST: 'onPost', PUT: 'onPut', DELETE: 'onDelete', }; const errorResponse = msg => ({ displayMessage: msg }); export const mockRequest = ({ method = 'GET', url, data, status = 200, response = null, }) => mock[methods[method.toUpperCase()]](url, data).reply(status, response); export const mockErrorRequest = ({ status = 500, ...options }) => mockRequest({ response: errorResponse(`Request failed with status code ${status}`), status, ...options, }); export const mockReset = () => mock.reset();
Version data entries
52 entries across 52 versions & 1 rubygems