Sha256: 27b9927f6a24fa1abd0d7ce0c35702ac4ae2d2e6c916ff3faebf95d05a2b07c0
Contents?: true
Size: 600 Bytes
Versions: 5
Compression:
Stored size: 600 Bytes
Contents
import nock from 'nock'; const createRequestMock = ({ bearerToken, host, method, params, path, responseStatus = 200, response, }) => { const reqheaders = { Authorization: `Bearer ${bearerToken}` }; const req = bearerToken ? nock(host, { reqheaders }) : nock(host); if (params) { return req[method](path, JSON.stringify(params)) .reply(responseStatus, response); } if (responseStatus >= 300) { return req[method](path) .replyWithError(response); } return req[method](path) .reply(responseStatus, response); }; export default createRequestMock;
Version data entries
5 entries across 5 versions & 1 rubygems