From a5afc258b1b126544c70601d7b8e9f2e70245148 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sat, 10 Jan 2015 22:09:37 +0000 Subject: [PATCH] Update unit tests --- red/nodes/Flow.js | 10 +- red/nodes/flows.js | 6 +- red/nodes/registry.js | 6 +- test/nodes/helper.js | 2 +- test/red/api/flows_spec.js | 4 +- test/red/nodes/Flow_spec.js | 0 test/red/nodes/Node_spec.js | 31 +- test/red/nodes/credentials_spec.js | 564 ++++++++++++++--------------- test/red/nodes/flows_spec.js | 42 +-- test/red/nodes/registry_spec.js | 13 +- 10 files changed, 342 insertions(+), 336 deletions(-) create mode 100644 test/red/nodes/Flow_spec.js diff --git a/red/nodes/Flow.js b/red/nodes/Flow.js index 8df35c88e..c54199142 100644 --- a/red/nodes/Flow.js +++ b/red/nodes/Flow.js @@ -207,12 +207,12 @@ function diffNodeConfigs(oldNode,newNode) { var subflowInstanceRE = /^subflow:(.+)$/; function Flow(config) { + this.activeNodes = {}; this.subflowInstanceNodes = {}; this.parseConfig(config); - } Flow.prototype.parseConfig = function(config) { @@ -385,6 +385,14 @@ Flow.prototype.getFlow = function() { return this.config; } +Flow.prototype.eachNode = function(callback) { + for (var id in this.activeNodes) { + if (this.activeNodes.hasOwnProperty(id)) { + callback(this.activeNodes[id]); + } + } +} + Flow.prototype.applyConfig = function(config,type) { var diff = this.diffFlow(config); //console.log(diff); diff --git a/red/nodes/flows.js b/red/nodes/flows.js index 685fed2d6..f4ad1d11b 100644 --- a/red/nodes/flows.js +++ b/red/nodes/flows.js @@ -81,6 +81,10 @@ var flowNodes = module.exports = { return activeFlow.getNode(i); }, + eachNode: function(cb) { + activeFlow.eachNode(cb); + }, + /** * Stops all active nodes and clears the active set * @return a promise for the stopping of all active nodes @@ -174,7 +178,7 @@ var flowNodes = module.exports = { var missingTypes = activeFlow.getMissingTypes(); if (missingTypes.length > 0) { util.log("[red] Waiting for missing types to be registered:"); - for (i=0;i