add failing socket error handling test
This commit is contained in:
parent
02ae4f787d
commit
2fe83a4e3d
2 changed files with 22 additions and 0 deletions
|
@ -131,6 +131,7 @@ app.callback = function(){
|
|||
|
||||
if (1 == ctx.socket.listeners('error').length) {
|
||||
ctx.socket.on('error', function(err){
|
||||
console.log('callback');
|
||||
self.emit('error', err);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -204,6 +204,27 @@ describe('app.respond', function(){
|
|||
})
|
||||
})
|
||||
|
||||
describe('when a socket error occurs', function(){
|
||||
it('should emit "error" on the app', function(done){
|
||||
var app = koa();
|
||||
|
||||
app.use(function(next){
|
||||
return function *(){
|
||||
this.socket.emit('error', new Error('tobi escaped'));
|
||||
}
|
||||
});
|
||||
|
||||
app.on('error', function(err){
|
||||
err.message.should.equal('tobi escaped');
|
||||
done();
|
||||
});
|
||||
|
||||
request(app.listen())
|
||||
.get('/')
|
||||
.end(function(){});
|
||||
})
|
||||
})
|
||||
|
||||
describe('when an error occurs', function(){
|
||||
it('should emit "error" on the app', function(done){
|
||||
var app = koa();
|
||||
|
|
Loading…
Reference in a new issue