I m trying to write unit test cases to handle error codes that are defined below. not sure how to achieve it.
module.exports = {
Error: Err,
BadRequest: function () {
return new Err(400, 'Bad Request');
},
NotAcceptable: function () {
return new Err(406, 'Not Acceptable');
},
NotAuthorized: function () {
return new Err(401, 'Not Authorized');
}
};
function Err(code, message) {
assert(code, 'code');
Error.call(this);
Error.captureStackTrace(this, this.constructor);
Object.defineProperty(this, 'code', {
enumerable: true,
value: code
});
this.reason = message;
}