fix text/plain response for 500 errors
This commit is contained in:
parent
28b5b85860
commit
228c38cf3e
2 changed files with 20 additions and 0 deletions
|
@ -608,6 +608,7 @@ module.exports = {
|
|||
|
||||
// respond
|
||||
this.status = 500;
|
||||
this.type = 'text';
|
||||
this.res.end('Internal Server Error');
|
||||
},
|
||||
|
||||
|
|
|
@ -162,6 +162,25 @@ describe('app.respond', function(){
|
|||
done();
|
||||
});
|
||||
})
|
||||
|
||||
it('should handle errors', function(done){
|
||||
var app = koa();
|
||||
|
||||
app.use(function(next){
|
||||
return function *(){
|
||||
this.set('Content-Type', 'application/json');
|
||||
this.body = fs.createReadStream('does not exist');
|
||||
}
|
||||
});
|
||||
|
||||
var server = app.listen();
|
||||
|
||||
request(server)
|
||||
.get('/')
|
||||
.expect('Content-Type', 'text/plain')
|
||||
.expect(500)
|
||||
.end(done);
|
||||
})
|
||||
})
|
||||
|
||||
describe('when .body is an Object', function(){
|
||||
|
|
Loading…
Reference in a new issue