mirror of
https://github.com/comatory/fb2iCal
synced 2025-02-11 09:10:56 +01:00
32 lines
496 B
JavaScript
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,
|
||
|
}
|