Browse Source

additional test to verify runAllCheck works for sanitizeAll

pull/942/head
Lily He 7 years ago
parent
commit
b9de4b6788
  1. 44
      test/unit/sanitizer/sanitizeAll.js

44
test/unit/sanitizer/sanitizeAll.js

@ -212,6 +212,50 @@ module.exports.tests.all = function(test, common) {
});
});
test('runAllChecks calls both sanitize and expectedParameters function', function(t) {
var req = {
query: {
value: 'query'
}
};
var sanitizers = {
'first': {
sanitize: function(params) {
req.clean.query = params;
return {
errors: [],
warnings: ['warning 1']
};
},
expected: function _expected () {
// add value as a valid parameter
return [{
name: 'value'
}];
}
}
};
var expected_req = {
query: {
value: 'query'
},
clean: {
query: {
value: 'query'
}
},
errors: [],
warnings: ['warning 1']
};
sanitizeAll.runAllChecks(req, sanitizers, function () {
t.deepEquals(req, expected_req);
t.end();
});
});
};
module.exports.all = function (tape, common) {

Loading…
Cancel
Save