mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
add test cases
This commit is contained in:
parent
93a88a83a8
commit
1ddbeaa50f
@ -260,7 +260,8 @@ describe('subflow', function() {
|
||||
{name: "KB", type: "bool", value: "true"},
|
||||
{name: "KJ", type: "json", value: "[1,2,3]"},
|
||||
{name: "Kb", type: "bin", value: "[65,65]"},
|
||||
{name: "Ke", type: "env", value: "KS"}
|
||||
{name: "Ke", type: "env", value: "KS"},
|
||||
{name: "Kj", type: "jsonata", value: "1+2"},
|
||||
],
|
||||
wires:[["n2"]]},
|
||||
{id:"n2", x:10, y:10, z:"t0", type:"helper", wires:[]},
|
||||
@ -279,7 +280,7 @@ describe('subflow', function() {
|
||||
]
|
||||
},
|
||||
{id:"s1-n1", x:10, y:10, z:"s1", type:"function",
|
||||
func:"msg.VE = env.get('Ke'); msg.VS = env.get('KS'); msg.VN = env.get('KN'); msg.VB = env.get('KB'); msg.VJ = env.get('KJ'); msg.Vb = env.get('Kb'); return msg;",
|
||||
func:"msg.VE = env.get('Ke'); msg.VS = env.get('KS'); msg.VN = env.get('KN'); msg.VB = env.get('KB'); msg.VJ = env.get('KJ'); msg.Vb = env.get('Kb'); msg.Vj = env.get('Kj'); return msg;",
|
||||
wires:[]}
|
||||
];
|
||||
helper.load(functionNode, flow, function() {
|
||||
@ -294,6 +295,7 @@ describe('subflow', function() {
|
||||
msg.should.have.property("Vb");
|
||||
should.ok(msg.Vb instanceof Buffer);
|
||||
msg.should.have.property("VE","STR");
|
||||
msg.should.have.property("Vj",3);
|
||||
done();
|
||||
}
|
||||
catch (e) {
|
||||
|
@ -1322,6 +1322,40 @@ describe('Flow', function() {
|
||||
|
||||
});
|
||||
|
||||
it("can define environment variable using JSONata", function (done) {
|
||||
try {
|
||||
after(function() {
|
||||
delete process.env.V0;
|
||||
})
|
||||
var config = flowUtils.parseConfig([
|
||||
{id:"t1",type:"tab",env:[
|
||||
{"name": "V0", value: "1+2", type: "jsonata"}
|
||||
]},
|
||||
{id:"g1",type:"group",z:"t1",env:[
|
||||
{"name": "V1", value: "2+3", type: "jsonata"},
|
||||
]},
|
||||
{id:"1",x:10,y:10,z:"t1",g:"g1",type:"test",foo:"$(V0)",wires:[]},
|
||||
{id:"2",x:10,y:10,z:"t1",g:"g1",type:"test",foo:"$(V1)",wires:[]},
|
||||
]);
|
||||
var flow = Flow.create({getSetting:v=>process.env[v]},config,config.flows["t1"]);
|
||||
flow.start();
|
||||
|
||||
var activeNodes = flow.getActiveNodes();
|
||||
|
||||
activeNodes["1"].foo.should.equal(3);
|
||||
activeNodes["2"].foo.should.equal(5);
|
||||
|
||||
flow.stop().then(function() {
|
||||
done();
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e.stack);
|
||||
done(e);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user