This commit is contained in:
shimks 2018-06-07 12:30:38 -04:00
parent 56d26b377e
commit b7b3961ff2
2 changed files with 40 additions and 40 deletions

View File

@ -64,7 +64,7 @@ function negotiateContentProducer(req, logWarning, options) {
} else { } else {
debug('contentType: `%s` is not supported, ' + debug('contentType: `%s` is not supported, ' +
'falling back to contentType: `%s`', 'falling back to contentType: `%s`',
options.defaultType, contentType); options.defaultType, contentType);
} }
} }

View File

@ -219,50 +219,50 @@ describe('strong-error-handler', function() {
}); });
it('includes code property for 4xx status codes when debug=false', it('includes code property for 4xx status codes when debug=false',
function(done) { function(done) {
var error = new ErrorWithProps({ var error = new ErrorWithProps({
statusCode: 400,
message: 'error with code',
name: 'ErrorWithCode',
code: 'MACHINE_READABLE_CODE',
});
givenErrorHandlerForError(error, {debug: false});
requestJson().end(function(err, res) {
if (err) return done(err);
var expectedData = {
statusCode: 400, statusCode: 400,
message: 'error with code', message: 'error with code',
name: 'ErrorWithCode', name: 'ErrorWithCode',
code: 'MACHINE_READABLE_CODE', code: 'MACHINE_READABLE_CODE',
}; });
expect(res.body).to.have.property('error'); givenErrorHandlerForError(error, {debug: false});
expect(res.body.error).to.eql(expectedData);
done(); requestJson().end(function(err, res) {
if (err) return done(err);
var expectedData = {
statusCode: 400,
message: 'error with code',
name: 'ErrorWithCode',
code: 'MACHINE_READABLE_CODE',
};
expect(res.body).to.have.property('error');
expect(res.body.error).to.eql(expectedData);
done();
});
}); });
});
it('excludes code property for 5xx status codes when debug=false', it('excludes code property for 5xx status codes when debug=false',
function(done) { function(done) {
var error = new ErrorWithProps({ var error = new ErrorWithProps({
statusCode: 500,
code: 'MACHINE_READABLE_CODE',
});
givenErrorHandlerForError(error, {debug: false});
requestJson().end(function(err, res) {
if (err) return done(err);
var expectedData = {
statusCode: 500, statusCode: 500,
message: 'Internal Server Error', code: 'MACHINE_READABLE_CODE',
}; });
expect(res.body).to.have.property('error'); givenErrorHandlerForError(error, {debug: false});
expect(res.body.error).to.eql(expectedData);
done(); requestJson().end(function(err, res) {
if (err) return done(err);
var expectedData = {
statusCode: 500,
message: 'Internal Server Error',
};
expect(res.body).to.have.property('error');
expect(res.body.error).to.eql(expectedData);
done();
});
}); });
});
it('contains non-enumerable Error properties when debug=true', it('contains non-enumerable Error properties when debug=true',
function(done) { function(done) {
@ -841,10 +841,10 @@ function setupHttpServerAndClient(done) {
request = supertest(app); request = supertest(app);
done(); done();
}) })
.once('error', function(err) { .once('error', function(err) {
debug('Cannot setup HTTP server: %s', err.stack); debug('Cannot setup HTTP server: %s', err.stack);
done(err); done(err);
}); });
} }
function stopHttpServerAndClient() { function stopHttpServerAndClient() {