From 4bc482bc8533300383b2af5fa17a0704a73e4875 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Mon, 18 Apr 2016 12:40:08 +0100 Subject: [PATCH] update load of grunt related versions and mqtt and fs-extra and should. Fix tests to keep working. --- package.json | 26 +- test/nodes/core/core/75-exec_spec.js | 345 ++++++++++++++------------- test/red/api/flows_spec.js | 3 +- test/red/api/nodes_spec.js | 3 +- test/red/runtime/settings_spec.js | 12 +- 5 files changed, 201 insertions(+), 188 deletions(-) diff --git a/package.json b/package.json index 29335a555..dca8868c1 100644 --- a/package.json +++ b/package.json @@ -34,12 +34,12 @@ "cron":"1.1.0", "express": "4.13.4", "follow-redirects":"0.0.7", - "fs-extra": "0.26.7", + "fs-extra": "0.27.0", "fs.notify":"0.0.4", "i18next":"1.10.6", "is-utf8":"0.2.1", "media-typer": "0.3.0", - "mqtt": "1.7.4", + "mqtt": "1.8.0", "mustache": "2.2.1", "nopt": "3.0.6", "oauth2orize":"1.2.2", @@ -66,21 +66,21 @@ "devDependencies": { "grunt": "0.4.5", "grunt-chmod": "1.1.1", - "grunt-cli": "0.1.13", - "grunt-concurrent":"2.2.1", - "grunt-contrib-clean":"0.7.0", - "grunt-contrib-compress": "0.14.0", - "grunt-contrib-concat":"0.5.1", - "grunt-contrib-copy": "0.8.2", - "grunt-contrib-jshint": "0.12.0", - "grunt-contrib-uglify": "0.11.1", - "grunt-contrib-watch":"0.6.1", + "grunt-cli": "1.2.0", + "grunt-concurrent":"2.3.0", + "grunt-contrib-clean":"1.0.0", + "grunt-contrib-compress": "1.2.0", + "grunt-contrib-concat":"1.0.0", + "grunt-contrib-copy": "1.0.0", + "grunt-contrib-jshint": "1.0.0", + "grunt-contrib-uglify": "1.0.1", + "grunt-contrib-watch":"1.0.0", "grunt-jsonlint":"1.0.7", - "grunt-nodemon":"0.4.1", + "grunt-nodemon":"0.4.2", "grunt-sass":"1.1.0", "grunt-simple-mocha": "0.4.1", "mocha": "2.4.5", - "should": "6.0.3", + "should": "8.3.1", "sinon": "1.17.3", "supertest": "1.2.0" }, diff --git a/test/nodes/core/core/75-exec_spec.js b/test/nodes/core/core/75-exec_spec.js index a4704a44c..99e5fbd64 100644 --- a/test/nodes/core/core/75-exec_spec.js +++ b/test/nodes/core/core/75-exec_spec.js @@ -45,189 +45,196 @@ describe('exec node', function() { }); }); - describe('calling exec', function() { + describe('calling exec', function() { - it('should exec a simple command', function(done) { - var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:false, append:""}, - {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}]; - var spy = sinon.stub(child_process, 'exec', - function(arg1,arg2,arg3,arg4){ - //console.log(arg1); - // arg3(error,stdout,stderr); - arg3(null,arg1,arg1.toUpperCase()); - }); + it('should exec a simple command', function(done) { + var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:false, append:""}, + {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}]; + var spy = sinon.stub(child_process, 'exec', + function(arg1,arg2,arg3,arg4){ + //console.log(arg1); + // arg3(error,stdout,stderr); + arg3(null,arg1,arg1.toUpperCase()); + }); - helper.load(execNode, flow, function() { - var n1 = helper.getNode("n1"); - var n2 = helper.getNode("n2"); - var n3 = helper.getNode("n3"); - var n4 = helper.getNode("n4"); - n2.on("input", function(msg) { - //console.log(msg); - msg.should.have.property("payload"); - msg.payload.should.be.a.String.and.equal("echo"); - }); - n3.on("input", function(msg) { - //console.log(msg); - msg.should.have.property("payload"); - msg.payload.should.be.a.String.and.equal("ECHO"); - done(); - child_process.exec.restore(); - }); - n1.receive({payload:"and"}); - }); - }); + helper.load(execNode, flow, function() { + var n1 = helper.getNode("n1"); + var n2 = helper.getNode("n2"); + var n3 = helper.getNode("n3"); + var n4 = helper.getNode("n4"); + n2.on("input", function(msg) { + //console.log(msg); + msg.should.have.property("payload"); + msg.payload.should.be.a.String; + msg.payload.should.equal("echo"); + }); + n3.on("input", function(msg) { + //console.log(msg); + msg.should.have.property("payload"); + msg.payload.should.be.a.String, + msg.payload.should.equal("ECHO"); + done(); + child_process.exec.restore(); + }); + n1.receive({payload:"and"}); + }); + }); - it('should exec a simple command with extra parameters', function(done) { - var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:true, append:"more"}, - {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}]; - var spy = sinon.stub(child_process, 'exec', - function(arg1,arg2,arg3,arg4){ - //console.log(arg1); - // arg3(error,stdout,stderr); - arg3(null,arg1,arg1.toUpperCase()); - }); + it('should exec a simple command with extra parameters', function(done) { + var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:true, append:"more"}, + {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}]; + var spy = sinon.stub(child_process, 'exec', + function(arg1,arg2,arg3,arg4){ + //console.log(arg1); + // arg3(error,stdout,stderr); + arg3(null,arg1,arg1.toUpperCase()); + }); - helper.load(execNode, flow, function() { - var n1 = helper.getNode("n1"); - var n2 = helper.getNode("n2"); - var n3 = helper.getNode("n3"); - var n4 = helper.getNode("n4"); - n2.on("input", function(msg) { - //console.log(msg); - msg.should.have.property("payload"); - msg.payload.should.be.a.String.and.equal("echo and more"); - }); - n3.on("input", function(msg) { - //console.log(msg); - msg.should.have.property("payload"); - msg.payload.should.be.a.String.and.equal("ECHO AND MORE"); - done(); - child_process.exec.restore(); - }); - n1.receive({payload:"and"}); - }); - }); + helper.load(execNode, flow, function() { + var n1 = helper.getNode("n1"); + var n2 = helper.getNode("n2"); + var n3 = helper.getNode("n3"); + var n4 = helper.getNode("n4"); + n2.on("input", function(msg) { + //console.log(msg); + msg.should.have.property("payload"); + msg.payload.should.be.a.String; + msg.payload.should.equal("echo and more"); + }); + n3.on("input", function(msg) { + //console.log(msg); + msg.should.have.property("payload"); + msg.payload.should.be.a.String; + msg.payload.should.equal("ECHO AND MORE"); + done(); + child_process.exec.restore(); + }); + n1.receive({payload:"and"}); + }); + }); - it('should be able to return a binary buffer', function(done) { - var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:true, append:"more"}, - {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}]; - var spy = sinon.stub(child_process, 'exec', - function(arg1,arg2,arg3,arg4){ - //console.log(arg1); - // arg3(error,stdout,stderr); - arg3("error",new Buffer([0x01,0x02,0x03]),""); - }); + it('should be able to return a binary buffer', function(done) { + var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:true, append:"more"}, + {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}]; + var spy = sinon.stub(child_process, 'exec', + function(arg1,arg2,arg3,arg4){ + //console.log(arg1); + // arg3(error,stdout,stderr); + arg3("error",new Buffer([0x01,0x02,0x03]),""); + }); - helper.load(execNode, flow, function() { - var n1 = helper.getNode("n1"); - var n2 = helper.getNode("n2"); - var n3 = helper.getNode("n3"); - var n4 = helper.getNode("n4"); - n2.on("input", function(msg) { - //console.log(msg); - msg.should.have.property("payload"); - msg.payload.should.be.a.Buffer; - msg.payload.length.should.equal(3); - }); - n4.on("input", function(msg) { - //console.log(msg); - msg.should.have.property("payload"); - msg.payload.should.be.a.String.and.equal("error"); - done(); - child_process.exec.restore(); - }); - n1.receive({payload:"and"}); - }); - }); - }); + helper.load(execNode, flow, function() { + var n1 = helper.getNode("n1"); + var n2 = helper.getNode("n2"); + var n3 = helper.getNode("n3"); + var n4 = helper.getNode("n4"); + n2.on("input", function(msg) { + //console.log(msg); + msg.should.have.property("payload"); + msg.payload.should.be.a.Buffer; + msg.payload.length.should.equal(3); + }); + n4.on("input", function(msg) { + //console.log(msg); + msg.should.have.property("payload"); + msg.payload.should.be.a.String; + msg.payload.should.equal("error"); + done(); + child_process.exec.restore(); + }); + n1.receive({payload:"and"}); + }); + }); + }); - describe.skip('calling spawn', function() { + describe.skip('calling spawn', function() { - it('should spawn a simple command', function(done) { - var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:true - , append:"", useSpawn:true}, - {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}]; - var events = require('events'); - //var spy = sinon.stub(child_process, 'spawn', - //function(arg1,arg2) { - //console.log(arg1,arg2); - //var blob = new events.EventEmitter; + it('should spawn a simple command', function(done) { + var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:true + , append:"", useSpawn:true}, + {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}]; + var events = require('events'); + //var spy = sinon.stub(child_process, 'spawn', + //function(arg1,arg2) { + //console.log(arg1,arg2); + //var blob = new events.EventEmitter; - //blob.stdout = function() { blob.emit("data","A"); } - //blob.stderr = function() { blob.emit("data","B"); } + //blob.stdout = function() { blob.emit("data","A"); } + //blob.stderr = function() { blob.emit("data","B"); } - //console.log("blob",blob); - //setTimeout( function() { - //blob.emit("close","CLOSE"); - //},150); + //console.log("blob",blob); + //setTimeout( function() { + //blob.emit("close","CLOSE"); + //},150); - //return blob; - //}); + //return blob; + //}); - helper.load(execNode, flow, function() { - var n1 = helper.getNode("n1"); - var n2 = helper.getNode("n2"); - var n3 = helper.getNode("n3"); - var n4 = helper.getNode("n4"); - n2.on("input", function(msg) { - //console.log(msg); - msg.should.have.property("payload"); - msg.payload.should.be.a.String.and.equal("hello world\n"); - done(); - //child_process.spawn.restore(); - }); - n1.receive({payload:"hello world"}); - }); - }); + helper.load(execNode, flow, function() { + var n1 = helper.getNode("n1"); + var n2 = helper.getNode("n2"); + var n3 = helper.getNode("n3"); + var n4 = helper.getNode("n4"); + n2.on("input", function(msg) { + //console.log(msg); + msg.should.have.property("payload"); + msg.payload.should.be.a.String; + msg.payload.should.equal("hello world\n"); + done(); + //child_process.spawn.restore(); + }); + n1.receive({payload:"hello world"}); + }); + }); - it('should spawn a simple command with a non string payload parameter', function(done) { - var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:true, append:" deg C", useSpawn:true}, - {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}]; - //var spy = sinon.stub(child_process, 'spawn', - //function(arg1,arg2) { - //console.log(arg1,arg2); - ////console.log(this); - //// arg3(error,stdout,stderr); - ////arg3(null,arg1,arg1.toUpperCase()); - //}); + it('should spawn a simple command with a non string payload parameter', function(done) { + var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:true, append:" deg C", useSpawn:true}, + {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}]; + //var spy = sinon.stub(child_process, 'spawn', + //function(arg1,arg2) { + //console.log(arg1,arg2); + ////console.log(this); + //// arg3(error,stdout,stderr); + ////arg3(null,arg1,arg1.toUpperCase()); + //}); - helper.load(execNode, flow, function() { - var n1 = helper.getNode("n1"); - var n2 = helper.getNode("n2"); - var n3 = helper.getNode("n3"); - var n4 = helper.getNode("n4"); - n2.on("input", function(msg) { - //console.log(msg); - msg.should.have.property("payload"); - msg.payload.should.be.a.String.and.equal("12345 deg C\n"); - done(); - }); - n1.receive({payload:12345}); - }); - }); + helper.load(execNode, flow, function() { + var n1 = helper.getNode("n1"); + var n2 = helper.getNode("n2"); + var n3 = helper.getNode("n3"); + var n4 = helper.getNode("n4"); + n2.on("input", function(msg) { + //console.log(msg); + msg.should.have.property("payload"); + msg.payload.should.be.a.String; + msg.payload.should.equal("12345 deg C\n"); + done(); + }); + n1.receive({payload:12345}); + }); + }); - it('should error if passed multiple words to spawn command', function(done) { - var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo this wont work", addpay:false, append:"", useSpawn:true}, - {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}]; - helper.load(execNode, flow, function() { - var n1 = helper.getNode("n1"); - var n2 = helper.getNode("n2"); - var n3 = helper.getNode("n3"); - var n4 = helper.getNode("n4"); - setTimeout(function() { - var logEvents = helper.log().args.filter(function(evt) { - return evt[0].type == "exec"; - }); - //console.log(logEvents); - logEvents.should.have.length(1); - logEvents[0][0].should.have.a.property('msg'); - logEvents[0][0].msg.toString().should.startWith("Spawn command"); - done(); - },150); - n1.receive({payload:null}); - }); - }); - }); + it('should error if passed multiple words to spawn command', function(done) { + var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo this wont work", addpay:false, append:"", useSpawn:true}, + {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}]; + helper.load(execNode, flow, function() { + var n1 = helper.getNode("n1"); + var n2 = helper.getNode("n2"); + var n3 = helper.getNode("n3"); + var n4 = helper.getNode("n4"); + setTimeout(function() { + var logEvents = helper.log().args.filter(function(evt) { + return evt[0].type == "exec"; + }); + //console.log(logEvents); + logEvents.should.have.length(1); + logEvents[0][0].should.have.a.property('msg'); + logEvents[0][0].msg.toString().should.startWith("Spawn command"); + done(); + },150);me + n1.receive({payload:null}); + }); + }); + }); }); diff --git a/test/red/api/flows_spec.js b/test/red/api/flows_spec.js index 970a0ea83..57a0db82b 100644 --- a/test/red/api/flows_spec.js +++ b/test/red/api/flows_spec.js @@ -49,7 +49,8 @@ describe("flows api", function() { if (err) { return done(err); } - res.body.should.be.an.Array.and.have.lengthOf(3); + res.body.should.be.an.Array; + res.body.should.have.lengthOf(3); done(); }); }); diff --git a/test/red/api/nodes_spec.js b/test/red/api/nodes_spec.js index 54218d206..98305216a 100644 --- a/test/red/api/nodes_spec.js +++ b/test/red/api/nodes_spec.js @@ -76,7 +76,8 @@ describe("nodes api", function() { if (err) { throw err; } - res.body.should.be.an.Array.and.have.lengthOf(3); + res.body.should.be.an.Array; + res.body.should.have.lengthOf(3); done(); }); }); diff --git a/test/red/runtime/settings_spec.js b/test/red/runtime/settings_spec.js index 933e39fa1..5bc08b296 100644 --- a/test/red/runtime/settings_spec.js +++ b/test/red/runtime/settings_spec.js @@ -37,11 +37,13 @@ describe("red/settings", function() { settings.a.should.equal(123); settings.b.should.equal("test"); - settings.c.should.be.an.Array.with.lengthOf(3); + settings.c.should.be.an.Array; + settings.c.should.have.lengthOf(3); settings.get("a").should.equal(123); settings.get("b").should.equal("test"); - settings.get("c").should.be.an.Array.with.lengthOf(3); + settings.get("c").should.be.an.Array; + settings.get("c").should.have.lengthOf(3); /*jshint immed: false */ (function() { @@ -49,7 +51,8 @@ describe("red/settings", function() { }).should.throw(); settings.c.push(5); - settings.c.should.be.an.Array.with.lengthOf(4); + settings.c.should.be.an.Array; + settings.c.should.have.lengthOf(4); /*jshint immed: false */ (function() { @@ -129,7 +132,8 @@ describe("red/settings", function() { settings.should.have.property("a",123); settings.should.have.property("b","test"); - settings.c.should.be.an.Array.with.lengthOf(3); + settings.c.should.be.an.Array; + settings.c.should.have.lengthOf(3); settings.reset();