1
0
mirror of https://github.com/comatory/fb2iCal synced 2025-02-06 11:53:23 +01:00
2020-07-15 20:54:24 +02:00

32 lines
496 B
JavaScript

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,
}