1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

update load of grunt related versions

and mqtt and fs-extra and should. Fix tests to keep working.
This commit is contained in:
Dave Conway-Jones 2016-04-18 12:40:08 +01:00
parent 0a1257a23a
commit 4bc482bc85
5 changed files with 201 additions and 188 deletions

View File

@ -34,12 +34,12 @@
"cron":"1.1.0", "cron":"1.1.0",
"express": "4.13.4", "express": "4.13.4",
"follow-redirects":"0.0.7", "follow-redirects":"0.0.7",
"fs-extra": "0.26.7", "fs-extra": "0.27.0",
"fs.notify":"0.0.4", "fs.notify":"0.0.4",
"i18next":"1.10.6", "i18next":"1.10.6",
"is-utf8":"0.2.1", "is-utf8":"0.2.1",
"media-typer": "0.3.0", "media-typer": "0.3.0",
"mqtt": "1.7.4", "mqtt": "1.8.0",
"mustache": "2.2.1", "mustache": "2.2.1",
"nopt": "3.0.6", "nopt": "3.0.6",
"oauth2orize":"1.2.2", "oauth2orize":"1.2.2",
@ -66,21 +66,21 @@
"devDependencies": { "devDependencies": {
"grunt": "0.4.5", "grunt": "0.4.5",
"grunt-chmod": "1.1.1", "grunt-chmod": "1.1.1",
"grunt-cli": "0.1.13", "grunt-cli": "1.2.0",
"grunt-concurrent":"2.2.1", "grunt-concurrent":"2.3.0",
"grunt-contrib-clean":"0.7.0", "grunt-contrib-clean":"1.0.0",
"grunt-contrib-compress": "0.14.0", "grunt-contrib-compress": "1.2.0",
"grunt-contrib-concat":"0.5.1", "grunt-contrib-concat":"1.0.0",
"grunt-contrib-copy": "0.8.2", "grunt-contrib-copy": "1.0.0",
"grunt-contrib-jshint": "0.12.0", "grunt-contrib-jshint": "1.0.0",
"grunt-contrib-uglify": "0.11.1", "grunt-contrib-uglify": "1.0.1",
"grunt-contrib-watch":"0.6.1", "grunt-contrib-watch":"1.0.0",
"grunt-jsonlint":"1.0.7", "grunt-jsonlint":"1.0.7",
"grunt-nodemon":"0.4.1", "grunt-nodemon":"0.4.2",
"grunt-sass":"1.1.0", "grunt-sass":"1.1.0",
"grunt-simple-mocha": "0.4.1", "grunt-simple-mocha": "0.4.1",
"mocha": "2.4.5", "mocha": "2.4.5",
"should": "6.0.3", "should": "8.3.1",
"sinon": "1.17.3", "sinon": "1.17.3",
"supertest": "1.2.0" "supertest": "1.2.0"
}, },

View File

@ -45,189 +45,196 @@ describe('exec node', function() {
}); });
}); });
describe('calling exec', function() { describe('calling exec', function() {
it('should exec a simple command', function(done) { it('should exec a simple command', function(done) {
var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:false, append:""}, 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"}]; {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}];
var spy = sinon.stub(child_process, 'exec', var spy = sinon.stub(child_process, 'exec',
function(arg1,arg2,arg3,arg4){ function(arg1,arg2,arg3,arg4){
//console.log(arg1); //console.log(arg1);
// arg3(error,stdout,stderr); // arg3(error,stdout,stderr);
arg3(null,arg1,arg1.toUpperCase()); arg3(null,arg1,arg1.toUpperCase());
}); });
helper.load(execNode, flow, function() { helper.load(execNode, flow, function() {
var n1 = helper.getNode("n1"); var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2"); var n2 = helper.getNode("n2");
var n3 = helper.getNode("n3"); var n3 = helper.getNode("n3");
var n4 = helper.getNode("n4"); var n4 = helper.getNode("n4");
n2.on("input", function(msg) { n2.on("input", function(msg) {
//console.log(msg); //console.log(msg);
msg.should.have.property("payload"); msg.should.have.property("payload");
msg.payload.should.be.a.String.and.equal("echo"); msg.payload.should.be.a.String;
}); msg.payload.should.equal("echo");
n3.on("input", function(msg) { });
//console.log(msg); n3.on("input", function(msg) {
msg.should.have.property("payload"); //console.log(msg);
msg.payload.should.be.a.String.and.equal("ECHO"); msg.should.have.property("payload");
done(); msg.payload.should.be.a.String,
child_process.exec.restore(); msg.payload.should.equal("ECHO");
}); done();
n1.receive({payload:"and"}); child_process.exec.restore();
}); });
}); n1.receive({payload:"and"});
});
});
it('should exec a simple command with extra parameters', function(done) { 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"}, 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"}]; {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}];
var spy = sinon.stub(child_process, 'exec', var spy = sinon.stub(child_process, 'exec',
function(arg1,arg2,arg3,arg4){ function(arg1,arg2,arg3,arg4){
//console.log(arg1); //console.log(arg1);
// arg3(error,stdout,stderr); // arg3(error,stdout,stderr);
arg3(null,arg1,arg1.toUpperCase()); arg3(null,arg1,arg1.toUpperCase());
}); });
helper.load(execNode, flow, function() { helper.load(execNode, flow, function() {
var n1 = helper.getNode("n1"); var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2"); var n2 = helper.getNode("n2");
var n3 = helper.getNode("n3"); var n3 = helper.getNode("n3");
var n4 = helper.getNode("n4"); var n4 = helper.getNode("n4");
n2.on("input", function(msg) { n2.on("input", function(msg) {
//console.log(msg); //console.log(msg);
msg.should.have.property("payload"); msg.should.have.property("payload");
msg.payload.should.be.a.String.and.equal("echo and more"); msg.payload.should.be.a.String;
}); msg.payload.should.equal("echo and more");
n3.on("input", function(msg) { });
//console.log(msg); n3.on("input", function(msg) {
msg.should.have.property("payload"); //console.log(msg);
msg.payload.should.be.a.String.and.equal("ECHO AND MORE"); msg.should.have.property("payload");
done(); msg.payload.should.be.a.String;
child_process.exec.restore(); msg.payload.should.equal("ECHO AND MORE");
}); done();
n1.receive({payload:"and"}); child_process.exec.restore();
}); });
}); n1.receive({payload:"and"});
});
});
it('should be able to return a binary buffer', function(done) { 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"}, 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"}]; {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}];
var spy = sinon.stub(child_process, 'exec', var spy = sinon.stub(child_process, 'exec',
function(arg1,arg2,arg3,arg4){ function(arg1,arg2,arg3,arg4){
//console.log(arg1); //console.log(arg1);
// arg3(error,stdout,stderr); // arg3(error,stdout,stderr);
arg3("error",new Buffer([0x01,0x02,0x03]),""); arg3("error",new Buffer([0x01,0x02,0x03]),"");
}); });
helper.load(execNode, flow, function() { helper.load(execNode, flow, function() {
var n1 = helper.getNode("n1"); var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2"); var n2 = helper.getNode("n2");
var n3 = helper.getNode("n3"); var n3 = helper.getNode("n3");
var n4 = helper.getNode("n4"); var n4 = helper.getNode("n4");
n2.on("input", function(msg) { n2.on("input", function(msg) {
//console.log(msg); //console.log(msg);
msg.should.have.property("payload"); msg.should.have.property("payload");
msg.payload.should.be.a.Buffer; msg.payload.should.be.a.Buffer;
msg.payload.length.should.equal(3); msg.payload.length.should.equal(3);
}); });
n4.on("input", function(msg) { n4.on("input", function(msg) {
//console.log(msg); //console.log(msg);
msg.should.have.property("payload"); msg.should.have.property("payload");
msg.payload.should.be.a.String.and.equal("error"); msg.payload.should.be.a.String;
done(); msg.payload.should.equal("error");
child_process.exec.restore(); done();
}); child_process.exec.restore();
n1.receive({payload:"and"}); });
}); n1.receive({payload:"and"});
}); });
}); });
});
describe.skip('calling spawn', function() { describe.skip('calling spawn', function() {
it('should spawn a simple command', function(done) { it('should spawn a simple command', function(done) {
var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:true var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:true
, append:"", useSpawn:true}, , append:"", useSpawn:true},
{id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}]; {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}];
var events = require('events'); var events = require('events');
//var spy = sinon.stub(child_process, 'spawn', //var spy = sinon.stub(child_process, 'spawn',
//function(arg1,arg2) { //function(arg1,arg2) {
//console.log(arg1,arg2); //console.log(arg1,arg2);
//var blob = new events.EventEmitter; //var blob = new events.EventEmitter;
//blob.stdout = function() { blob.emit("data","A"); } //blob.stdout = function() { blob.emit("data","A"); }
//blob.stderr = function() { blob.emit("data","B"); } //blob.stderr = function() { blob.emit("data","B"); }
//console.log("blob",blob); //console.log("blob",blob);
//setTimeout( function() { //setTimeout( function() {
//blob.emit("close","CLOSE"); //blob.emit("close","CLOSE");
//},150); //},150);
//return blob; //return blob;
//}); //});
helper.load(execNode, flow, function() { helper.load(execNode, flow, function() {
var n1 = helper.getNode("n1"); var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2"); var n2 = helper.getNode("n2");
var n3 = helper.getNode("n3"); var n3 = helper.getNode("n3");
var n4 = helper.getNode("n4"); var n4 = helper.getNode("n4");
n2.on("input", function(msg) { n2.on("input", function(msg) {
//console.log(msg); //console.log(msg);
msg.should.have.property("payload"); msg.should.have.property("payload");
msg.payload.should.be.a.String.and.equal("hello world\n"); msg.payload.should.be.a.String;
done(); msg.payload.should.equal("hello world\n");
//child_process.spawn.restore(); done();
}); //child_process.spawn.restore();
n1.receive({payload:"hello world"}); });
}); n1.receive({payload:"hello world"});
}); });
});
it('should spawn a simple command with a non string payload parameter', function(done) { 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}, 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"}]; {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}];
//var spy = sinon.stub(child_process, 'spawn', //var spy = sinon.stub(child_process, 'spawn',
//function(arg1,arg2) { //function(arg1,arg2) {
//console.log(arg1,arg2); //console.log(arg1,arg2);
////console.log(this); ////console.log(this);
//// arg3(error,stdout,stderr); //// arg3(error,stdout,stderr);
////arg3(null,arg1,arg1.toUpperCase()); ////arg3(null,arg1,arg1.toUpperCase());
//}); //});
helper.load(execNode, flow, function() { helper.load(execNode, flow, function() {
var n1 = helper.getNode("n1"); var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2"); var n2 = helper.getNode("n2");
var n3 = helper.getNode("n3"); var n3 = helper.getNode("n3");
var n4 = helper.getNode("n4"); var n4 = helper.getNode("n4");
n2.on("input", function(msg) { n2.on("input", function(msg) {
//console.log(msg); //console.log(msg);
msg.should.have.property("payload"); msg.should.have.property("payload");
msg.payload.should.be.a.String.and.equal("12345 deg C\n"); msg.payload.should.be.a.String;
done(); msg.payload.should.equal("12345 deg C\n");
}); done();
n1.receive({payload:12345}); });
}); n1.receive({payload:12345});
}); });
});
it('should error if passed multiple words to spawn command', function(done) { 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}, 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"}]; {id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}];
helper.load(execNode, flow, function() { helper.load(execNode, flow, function() {
var n1 = helper.getNode("n1"); var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2"); var n2 = helper.getNode("n2");
var n3 = helper.getNode("n3"); var n3 = helper.getNode("n3");
var n4 = helper.getNode("n4"); var n4 = helper.getNode("n4");
setTimeout(function() { setTimeout(function() {
var logEvents = helper.log().args.filter(function(evt) { var logEvents = helper.log().args.filter(function(evt) {
return evt[0].type == "exec"; return evt[0].type == "exec";
}); });
//console.log(logEvents); //console.log(logEvents);
logEvents.should.have.length(1); logEvents.should.have.length(1);
logEvents[0][0].should.have.a.property('msg'); logEvents[0][0].should.have.a.property('msg');
logEvents[0][0].msg.toString().should.startWith("Spawn command"); logEvents[0][0].msg.toString().should.startWith("Spawn command");
done(); done();
},150); },150);me
n1.receive({payload:null}); n1.receive({payload:null});
}); });
}); });
}); });
}); });

View File

@ -49,7 +49,8 @@ describe("flows api", function() {
if (err) { if (err) {
return done(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(); done();
}); });
}); });

View File

@ -76,7 +76,8 @@ describe("nodes api", function() {
if (err) { if (err) {
throw 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(); done();
}); });
}); });

View File

@ -37,11 +37,13 @@ describe("red/settings", function() {
settings.a.should.equal(123); settings.a.should.equal(123);
settings.b.should.equal("test"); 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("a").should.equal(123);
settings.get("b").should.equal("test"); 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 */ /*jshint immed: false */
(function() { (function() {
@ -49,7 +51,8 @@ describe("red/settings", function() {
}).should.throw(); }).should.throw();
settings.c.push(5); 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 */ /*jshint immed: false */
(function() { (function() {
@ -129,7 +132,8 @@ describe("red/settings", function() {
settings.should.have.property("a",123); settings.should.have.property("a",123);
settings.should.have.property("b","test"); 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(); settings.reset();