1
0
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:
Ondřej Synáček
2020-07-14 11:49:56 +02:00
parent 56be0e9730
commit d9212f707b
5 changed files with 4911 additions and 2 deletions

31
mocks/request.mock.js Normal file
View 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,
}