mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge branch 'master' into 0.16
This commit is contained in:
@@ -34,7 +34,20 @@ describe('flows/util', function() {
|
||||
getType.restore();
|
||||
});
|
||||
|
||||
|
||||
describe('#mapEnvVarProperties',function() {
|
||||
it('handles ENV substitutions in an object', function() {
|
||||
process.env.foo1 = "bar1";
|
||||
process.env.foo2 = "bar2";
|
||||
process.env.foo3 = "bar3";
|
||||
var foo = {a:"$(foo1)",b:"$(foo2)",c:{d:"$(foo3)"}};
|
||||
for (var p in foo) {
|
||||
if (foo.hasOwnProperty(p)) {
|
||||
flowUtil.mapEnvVarProperties(foo,p);
|
||||
}
|
||||
}
|
||||
foo.should.eql({ a: 'bar1', b: 'bar2', c: { d: 'bar3' } } );
|
||||
});
|
||||
});
|
||||
|
||||
describe('#diffNodes',function() {
|
||||
it('handles a null old node', function() {
|
||||
@@ -189,7 +202,7 @@ describe('flows/util', function() {
|
||||
|
||||
});
|
||||
it('identifies nodes with changed properties, including upstream linked', function() {
|
||||
var config = [{id:"1",type:"test",foo:"a",wires:[]},{id:"2",type:"test",bar:"b",wires:[["1"]]},{id:"3",type:"test",foo:"a",wires:[]}];
|
||||
var config = [{id:"1",type:"test",foo:"a",wires:[]},{id:"2",type:"test",bar:"b",wires:[["1"]]},{id:"3",type:"test",foo:"a",wires:[]}];
|
||||
var newConfig = clone(config);
|
||||
newConfig[1].bar = "c";
|
||||
|
||||
@@ -207,7 +220,7 @@ describe('flows/util', function() {
|
||||
});
|
||||
|
||||
it('identifies nodes with changed credentials, including downstream linked', function() {
|
||||
var config = [{id:"1",type:"test",wires:[]},{id:"2",type:"test",bar:"b",wires:[["1"]]},{id:"3",type:"test",foo:"a",wires:[]}];
|
||||
var config = [{id:"1",type:"test",wires:[]},{id:"2",type:"test",bar:"b",wires:[["1"]]},{id:"3",type:"test",foo:"a",wires:[]}];
|
||||
var newConfig = clone(config);
|
||||
newConfig[0].credentials = {};
|
||||
|
||||
@@ -225,7 +238,7 @@ describe('flows/util', function() {
|
||||
});
|
||||
|
||||
it('identifies nodes with changed wiring', function() {
|
||||
var config = [{id:"1",type:"test",foo:"a",wires:[]},{id:"2",type:"test",bar:"b",wires:[["1"]]},{id:"3",type:"test",foo:"a",wires:[]}];
|
||||
var config = [{id:"1",type:"test",foo:"a",wires:[]},{id:"2",type:"test",bar:"b",wires:[["1"]]},{id:"3",type:"test",foo:"a",wires:[]}];
|
||||
var newConfig = clone(config);
|
||||
newConfig[1].wires[0][0] = "3";
|
||||
|
||||
@@ -243,7 +256,7 @@ describe('flows/util', function() {
|
||||
});
|
||||
|
||||
it('identifies nodes with changed wiring - second connection added', function() {
|
||||
var config = [{id:"1",type:"test",foo:"a",wires:[]},{id:"2",type:"test",bar:"b",wires:[["1"]]},{id:"3",type:"test",foo:"a",wires:[]}];
|
||||
var config = [{id:"1",type:"test",foo:"a",wires:[]},{id:"2",type:"test",bar:"b",wires:[["1"]]},{id:"3",type:"test",foo:"a",wires:[]}];
|
||||
var newConfig = clone(config);
|
||||
newConfig[1].wires[0].push("1");
|
||||
|
||||
@@ -261,7 +274,7 @@ describe('flows/util', function() {
|
||||
});
|
||||
|
||||
it('identifies nodes with changed wiring - node connected', function() {
|
||||
var config = [{id:"1",type:"test",foo:"a",wires:[["2"]]},{id:"2",type:"test",bar:"b",wires:[[]]},{id:"3",type:"test",foo:"a",wires:[]}];
|
||||
var config = [{id:"1",type:"test",foo:"a",wires:[["2"]]},{id:"2",type:"test",bar:"b",wires:[[]]},{id:"3",type:"test",foo:"a",wires:[]}];
|
||||
var newConfig = clone(config);
|
||||
newConfig[1].wires.push("3");
|
||||
|
||||
|
@@ -38,8 +38,9 @@ describe("red/nodes/index", function() {
|
||||
index.clearRegistry();
|
||||
});
|
||||
|
||||
process.env.foo="bar";
|
||||
var testFlows = [{"type":"test","id":"tab1","label":"Sheet 1"}];
|
||||
var testCredentials = {"tab1":{"b":1,"c":2}};
|
||||
var testCredentials = {"tab1":{"b":1, "c":"2", "d":"$(foo)"}};
|
||||
var storage = {
|
||||
getFlows: function() {
|
||||
return when({red:123,flows:testFlows,credentials:testCredentials});
|
||||
@@ -58,7 +59,7 @@ describe("red/nodes/index", function() {
|
||||
var runtime = {
|
||||
settings: settings,
|
||||
storage: storage,
|
||||
log: {debug:function(){},warn:function(){}}
|
||||
log: {debug:function() {}, warn:function() {}}
|
||||
};
|
||||
|
||||
function TestNode(n) {
|
||||
@@ -75,7 +76,8 @@ describe("red/nodes/index", function() {
|
||||
index.loadFlows().then(function() {
|
||||
var testnode = new TestNode({id:'tab1',type:'test',name:'barney'});
|
||||
testnode.credentials.should.have.property('b',1);
|
||||
testnode.credentials.should.have.property('c',2);
|
||||
testnode.credentials.should.have.property('c',"2");
|
||||
testnode.credentials.should.have.property('d',"bar");
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
done(err);
|
||||
|
@@ -317,6 +317,53 @@ describe("red/nodes/registry/loader",function() {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it("load core node files scanned by lfs - missing html file", function(done) {
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles", function(){
|
||||
var result = {};
|
||||
result["node-red"] = {
|
||||
"name": "node-red",
|
||||
"nodes": {
|
||||
"DuffNode": {
|
||||
"file": path.join(resourcesDir,"DuffNode","DuffNode.js"),
|
||||
"module": "node-red",
|
||||
"name": "DuffNode"
|
||||
}
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}));
|
||||
|
||||
stubs.push(sinon.stub(registry,"saveNodeList", function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"addNodeSet", function(){ return }));
|
||||
// This module isn't already loaded
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo", function(){ return null; }));
|
||||
|
||||
stubs.push(sinon.stub(nodes,"registerType"));
|
||||
loader.init({nodes:nodes,i18n:{defaultLang:"en-US"},events:{on:function(){},removeListener:function(){}},log:{info:function(){},_:function(){}},settings:{available:function(){return true;}}});
|
||||
loader.load().then(function(result) {
|
||||
registry.addNodeSet.called.should.be.true();
|
||||
registry.addNodeSet.lastCall.args[0].should.eql("node-red/DuffNode");
|
||||
registry.addNodeSet.lastCall.args[1].should.have.a.property('id',"node-red/DuffNode");
|
||||
registry.addNodeSet.lastCall.args[1].should.have.a.property('module',"node-red");
|
||||
registry.addNodeSet.lastCall.args[1].should.have.a.property('enabled',true);
|
||||
registry.addNodeSet.lastCall.args[1].should.have.a.property('loaded',false);
|
||||
registry.addNodeSet.lastCall.args[1].should.have.a.property('version',undefined);
|
||||
registry.addNodeSet.lastCall.args[1].should.have.a.property('types');
|
||||
registry.addNodeSet.lastCall.args[1].types.should.have.a.length(0);
|
||||
registry.addNodeSet.lastCall.args[1].should.not.have.a.property('config');
|
||||
registry.addNodeSet.lastCall.args[1].should.not.have.a.property('help');
|
||||
registry.addNodeSet.lastCall.args[1].should.not.have.a.property('namespace','node-red');
|
||||
registry.addNodeSet.lastCall.args[1].should.have.a.property('err');
|
||||
registry.addNodeSet.lastCall.args[1].err.should.endWith("DuffNode.html does not exist");
|
||||
|
||||
nodes.registerType.calledOnce.should.be.false();
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("#addModule",function() {
|
||||
|
@@ -0,0 +1,5 @@
|
||||
// A test node that exports a function
|
||||
module.exports = function(RED) {
|
||||
function DuffNode(n) {}
|
||||
RED.nodes.registerType("duff-node",DuffNode);
|
||||
}
|
@@ -337,6 +337,11 @@ describe("red/util", function() {
|
||||
it("pass 'a.b'.c",function() { testABC("'a.b'.c",['a.b','c']); })
|
||||
|
||||
|
||||
it('pass a.$b.c',function() { testABC('a.$b.c',['a','$b','c']); })
|
||||
it('pass a["$b"].c',function() { testABC('a["$b"].c',['a','$b','c']); })
|
||||
it('pass a._b.c',function() { testABC('a._b.c',['a','_b','c']); })
|
||||
it('pass a["_b"].c',function() { testABC('a["_b"].c',['a','_b','c']); })
|
||||
|
||||
it("fail a'b'.c",function() { testInvalid("a'b'.c"); })
|
||||
it("fail a['b'.c",function() { testInvalid("a['b'.c"); })
|
||||
it("fail a[]",function() { testInvalid("a[]"); })
|
||||
|
Reference in New Issue
Block a user