Files
hiring-test-one/test/common.js
Lloyd Brookes 71b2f4dcb4 update tests
2016-06-20 01:02:51 +01:00

23 lines
483 B
JavaScript

'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)
}
}