From a87548a9914d7e867f389f4450a990714be26836 Mon Sep 17 00:00:00 2001 From: hbeeken Date: Mon, 2 Feb 2015 13:21:19 +0000 Subject: [PATCH] Fixing test where part wasn't exercised --- test/red/nodes/Node_spec.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/test/red/nodes/Node_spec.js b/test/red/nodes/Node_spec.js index 65980bb3c..a5f0ca9b5 100644 --- a/test/red/nodes/Node_spec.js +++ b/test/red/nodes/Node_spec.js @@ -264,7 +264,7 @@ describe('Node', function() { }); it('emits messages without cloning req or res', function(done) { - var n1 = new RedNode({id:'n1',type:'abc',wires:[['n2'],['n3']]}); + var n1 = new RedNode({id:'n1',type:'abc',wires:[[['n2'],['n3']]]}); var n2 = new RedNode({id:'n2',type:'abc'}); var n3 = new RedNode({id:'n3',type:'abc'}); var flowGet = sinon.stub(flows,"get",function(id) { @@ -276,24 +276,33 @@ describe('Node', function() { var cloned = {}; var message = {payload: "foo", cloned: cloned, req: req, res: res}; + var rcvdCount = 0; + // first message to be sent, so should not be cloned n2.on('input',function(msg) { should.deepEqual(msg, message); msg.cloned.should.be.exactly(message.cloned); msg.req.should.be.exactly(message.req); msg.res.should.be.exactly(message.res); - flowGet.restore(); - done(); + rcvdCount += 1; + if (rcvdCount == 2) { + flowGet.restore(); + done(); + } }); // second message to be sent, so should be cloned + // message uuids wont match since we've cloned n3.on('input',function(msg) { - should.deepEqual(msg, message); + msg.payload.should.equal(message.payload); msg.cloned.should.not.be.exactly(message.cloned); msg.req.should.be.exactly(message.req); msg.res.should.be.exactly(message.res); - flowGet.restore(); - done(); + rcvdCount += 1; + if (rcvdCount == 2) { + flowGet.restore(); + done(); + } }); n1.send(message);