From 820ca4475d5fd2795cbef23651aa366043465638 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 14 May 2014 21:46:07 +0100 Subject: [PATCH] Add tests for async close --- test/node_spec.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/test/node_spec.js b/test/node_spec.js index f72cc08af..642458367 100644 --- a/test/node_spec.js +++ b/test/node_spec.js @@ -48,11 +48,29 @@ describe('Node', function() { describe('#close', function() { it('emits close event when closed',function(done) { var n = new RedNode({id:'123',type:'abc'}); - n.on('close',done); - n.close(); + n.on('close',function() { + done(); + }); + var p = n.close(); + should.not.exist(p); + }); + + it('returns a promise when provided a callback with a done parameter',function(testdone) { + var n = new RedNode({id:'123',type:'abc'}); + n.on('close',function(done) { + setTimeout(function() { + done(); + },200); + }); + var p = n.close(); + should.exist(p); + p.then(function() { + testdone(); + }); }); }); + describe('#receive', function() { it('emits input event when called', function(done) { var n = new RedNode({id:'123',type:'abc'});