You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

22 lines
483 B

'use strict'
const arrayify = require('array-back')
exports.checkResponse = checkResponse
exports.fail = fail
function checkResponse (t, status, bodyTests) {
return function (response) {
if (status) t.strictEqual(response.res.statusCode, status)
if (bodyTests) {
arrayify(bodyTests).forEach(body => {
t.ok(body.test(response.data), 'correct data')
})
}
}
}
function fail (t) {
return function (err) {
t.fail('failed: ' + err.stack)
}
}