From 69f85bd68841ac82b2080f99492cbf7ae723df4e Mon Sep 17 00:00:00 2001 From: dceejay Date: Fri, 6 Mar 2015 22:58:30 +0000 Subject: [PATCH] boost api index, nodes index and nodes Node test coverage --- red/nodes/Node.js | 30 ++++++++++++++++++------------ test/red/api/index_spec.js | 19 +++++++++++-------- test/red/log_spec.js | 2 +- test/red/nodes/Node_spec.js | 29 +++++++++++++++++++++-------- test/red/nodes/index_spec.js | 4 +--- 5 files changed, 52 insertions(+), 32 deletions(-) diff --git a/red/nodes/Node.js b/red/nodes/Node.js index 3f2115530..7f8901d52 100644 --- a/red/nodes/Node.js +++ b/red/nodes/Node.js @@ -29,7 +29,7 @@ function Node(n) { this.type = n.type; this.z = n.z; this._closeCallbacks = []; - + if (n.name) { this.name = n.name; } @@ -41,7 +41,7 @@ util.inherits(Node, EventEmitter); Node.prototype.updateWires = function(wires) { this.wires = wires || []; delete this._wire; - + var wc = 0; this.wires.forEach(function(w) { wc+=w.length; @@ -103,10 +103,10 @@ function constructUniqueIdentifier() { Node.prototype.send = function(msg) { var msgSent = false; var node; - + if (msg === null || typeof msg === "undefined") { return; - } else if (!util.isArray(msg)) { + } else if (!util.isArray(msg)) { if (this._wire) { // A single message and a single wire on output 0 // TODO: pre-load flows.get calls - cannot do in constructor @@ -116,6 +116,7 @@ Node.prototype.send = function(msg) { } this.metric("send",msg); node = flows.get(this._wire); + /* istanbul ignore else */ if (node) { node.receive(msg); } @@ -124,18 +125,19 @@ Node.prototype.send = function(msg) { msg = [msg]; } } - + var numOutputs = this.wires.length; - + // Build a list of send events so that all cloning is done before // any calls to node.receive var sendEvents = []; - + var sentMessageId = null; - + // for each output of node eg. [msgs to output 0, msgs to output 1, ...] for (var i = 0; i < numOutputs; i++) { var wires = this.wires[i]; // wires leaving output i + /* istanbul ignore else */ if (i < msg.length) { var msgs = msg[i]; // msgs going to output i if (msgs !== null && typeof msgs !== "undefined") { @@ -150,6 +152,7 @@ Node.prototype.send = function(msg) { // for each msg to send eg. [[m1, m2, ...], ...] for (k = 0; k < msgs.length; k++) { var m = msgs[k]; + /* istanbul ignore else */ if (!sentMessageId) { sentMessageId = m._msgid; } @@ -166,13 +169,15 @@ Node.prototype.send = function(msg) { } } } + /* istanbul ignore else */ if (!sentMessageId) { sentMessageId = constructUniqueIdentifier(); } this.metric("send",{_msgid:sentMessageId}); - + for (i=0;i