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.

61 lines
1.3 KiB

'use strict';
const _ = require('lodash');
const has_response_data = require('../../../../controller/predicates/has_response_data');
module.exports.tests = {};
module.exports.tests.interface = (test, common) => {
test('valid interface', (t) => {
t.equal(typeof has_response_data, 'function', 'has_response_data is a function');
t.end();
});
};
module.exports.tests.true_conditions = (test, common) => {
test('response with non-empty data should return true', (t) => {
const req = {};
const res = {
data: [1]
};
t.ok(has_response_data(req, res));
t.end();
});
};
module.exports.tests.false_conditions = (test, common) => {
test('response with undefined data should return true', (t) => {
const req = {};
const res = {};
t.notOk(has_response_data(req, res));
t.end();
});
test('response with empty data array should return true', (t) => {
const req = {};
const res = {
data: []
};
t.notOk(has_response_data(req, res));
t.end();
});
};
module.exports.all = (tape, common) => {
function test(name, testFunction) {
return tape(`GET /has_response_data ${name}`, testFunction);
}
for( const testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};