2021-03-04 19:01:25 +01:00
|
|
|
const fs = require('fs').promises
|
|
|
|
|
2021-03-09 21:24:22 +01:00
|
|
|
async function got(url) {
|
|
|
|
console.log(`through got mock, url ${url}`)
|
|
|
|
if(url.indexOf('/webmention') >= 0) {
|
|
|
|
const result = await fs.readFile(`./test/__mocks__/get-sample.json`, 'utf8');
|
|
|
|
return {
|
2021-03-12 19:03:56 +01:00
|
|
|
// WHY not a JSON.parse here? The body is a STRING IRL!
|
|
|
|
body: result
|
2021-03-09 21:24:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-14 21:21:47 +01:00
|
|
|
const result = await fs.readFile(`./test/__mocks__/${url}.xml`, 'utf8');
|
2021-03-09 21:24:22 +01:00
|
|
|
return result
|
2021-03-04 19:01:25 +01:00
|
|
|
}
|
|
|
|
|
2021-03-17 22:15:43 +01:00
|
|
|
async function gotPutMock(url, opts) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
got.put = gotPutMock
|
|
|
|
|
2021-03-04 19:01:25 +01:00
|
|
|
module.exports = got
|