Ensure errors in node.receive are handled

This commit is contained in:
Nick O'Leary
2015-05-02 22:15:33 +01:00
parent 0c5c3448d0
commit 51fce9343b
2 changed files with 19 additions and 1 deletions

View File

@@ -133,6 +133,20 @@ describe('Node', function() {
});
n.receive(null);
});
it('handles thrown errors', function(done) {
var n = new RedNode({id:'123',type:'abc'});
sinon.stub(n,"error",function(err,msg) {});
var message = {payload:"hello world"};
n.on('input',function(msg) {
throw new Error("test error");
});
n.receive(message);
n.error.called.should.be.true;
n.error.firstCall.args[1].should.equal(message);
done();
});
});
describe('#send', function() {