Facebook-Events-iCal-Converter/mocks/request.mock.js

32 lines
496 B
JavaScript
Raw Normal View History

2020-07-14 11:49:56 +02:00
const sinon = jest.requireActual('sinon')
let currentSpy = null
const mockRequest = (options) => {
try {
const spy = currentSpy || sinon.spy()
console.info(`mock request ${JSON.stringify(options)}`)
spy(options)
} catch (err) {
console.trace(err)
}
}
const setRequestSpy = () => {
const spy = sinon.spy()
currentSpy = spy
return spy
}
const clearRequestSpy = () => {
currentSpy = null
}
module.exports = {
mockRequest,
setRequestSpy,
clearRequestSpy,
}