mirror of
https://github.com/comatory/fb2iCal
synced 2025-06-05 22:09:25 +02:00
add specs for crawler service
This commit is contained in:
31
mocks/request.mock.js
Normal file
31
mocks/request.mock.js
Normal file
@ -0,0 +1,31 @@
|
||||
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,
|
||||
}
|
Reference in New Issue
Block a user