2014-08-14 15:37:27 +02:00
|
|
|
/**
|
2017-01-11 16:24:33 +01:00
|
|
|
* Copyright JS Foundation and other contributors, http://js.foundation
|
2014-08-14 15:37:27 +02:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
**/
|
|
|
|
|
|
|
|
var should = require("should");
|
2018-07-07 23:23:26 +02:00
|
|
|
var sinon = require("sinon");
|
2014-08-14 15:37:27 +02:00
|
|
|
|
|
|
|
var changeNode = require("../../../../nodes/core/logic/15-change.js");
|
2018-07-11 16:39:34 +02:00
|
|
|
var Context = require("../../../../red/runtime/nodes/context");
|
2018-03-02 05:41:16 +01:00
|
|
|
var helper = require("node-red-node-test-helper");
|
2014-08-14 15:37:27 +02:00
|
|
|
|
2015-03-24 18:35:54 +01:00
|
|
|
describe('change Node', function() {
|
2014-10-07 15:46:43 +02:00
|
|
|
|
2014-08-14 15:37:27 +02:00
|
|
|
beforeEach(function(done) {
|
2018-07-14 04:00:57 +02:00
|
|
|
helper.startServer(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
function initContext(done) {
|
2018-07-11 16:39:34 +02:00
|
|
|
Context.init({
|
|
|
|
contextStorage: {
|
2018-07-14 04:00:57 +02:00
|
|
|
memory0: {
|
|
|
|
module: "memory"
|
|
|
|
},
|
|
|
|
memory1: {
|
2018-07-11 16:39:34 +02:00
|
|
|
module: "memory"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-07-13 10:34:04 +02:00
|
|
|
Context.load().then(function () {
|
2018-07-14 04:00:57 +02:00
|
|
|
done();
|
2018-07-13 10:34:04 +02:00
|
|
|
});
|
2018-07-14 04:00:57 +02:00
|
|
|
}
|
2014-10-07 15:46:43 +02:00
|
|
|
|
2014-08-14 15:37:27 +02:00
|
|
|
afterEach(function(done) {
|
2018-07-13 10:34:04 +02:00
|
|
|
helper.unload().then(function () {
|
|
|
|
return Context.clean({allNodes: {}});
|
|
|
|
}).then(function () {
|
|
|
|
return Context.close();
|
|
|
|
}).then(function () {
|
|
|
|
helper.stopServer(done);
|
|
|
|
});
|
2014-08-14 15:37:27 +02:00
|
|
|
});
|
|
|
|
|
2015-03-24 18:35:54 +01:00
|
|
|
it('should load node with defaults', function(done) {
|
|
|
|
var flow = [{ id: "c1", type: "change", name:"change1" }];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
helper.getNode("c1").should.have.property("name", "change1");
|
2015-12-29 23:19:32 +01:00
|
|
|
helper.getNode("c1").should.have.property("rules", [{fromt:'str',pt:'msg',tot:'str',t:undefined,p:''}]);
|
2015-03-24 18:35:54 +01:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('should load defaults if set to replace', function(done) {
|
|
|
|
var flow = [{ id: "c1", type: "change", name:"change1", action:"replace" }];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
helper.getNode("c1").should.have.property("name", "change1");
|
2015-12-29 23:19:32 +01:00
|
|
|
helper.getNode("c1").should.have.property("rules", [ {fromt: 'str', p: '', pt: 'msg', t: 'set', to: '', tot: 'str'} ]);
|
2015-03-24 18:35:54 +01:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('should load defaults if set to change', function(done) {
|
2016-10-10 12:10:36 +02:00
|
|
|
var flow = [{ id: "c1", type: "change", name:"change1", action:"change" }];
|
2015-03-24 18:35:54 +01:00
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
//console.log(helper.getNode("c1"));
|
|
|
|
helper.getNode("c1").should.have.property("name", "change1");
|
2016-03-14 00:10:10 +01:00
|
|
|
helper.getNode("c1").should.have.property("rules", [ { from: '', fromRE:/(?:)/g,fromt: 'str', p: '',pt: 'msg', re: undefined, t: 'change', to: '',tot: 'str' } ]);
|
2015-03-24 18:35:54 +01:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-12-29 23:19:32 +01:00
|
|
|
describe('#set' , function() {
|
2015-03-24 18:35:54 +01:00
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('sets the value of the message property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"replace","property":"payload","from":"","to":"changed","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("changed");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"changeMe"});
|
2014-08-14 15:37:27 +02:00
|
|
|
});
|
|
|
|
});
|
2014-10-07 15:46:43 +02:00
|
|
|
|
2017-11-17 18:26:36 +01:00
|
|
|
it('sets the value of global context property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t":"set","p":"globalValue","pt":"global","to":"changed","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
changeNode1.context().global.get("globalValue").should.equal("changed");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().global.set("globalValue","changeMe");
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-11 16:39:34 +02:00
|
|
|
it('sets the value of persistable global context property', function(done) {
|
2018-07-14 04:00:57 +02:00
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t":"set","p":"#:(memory0)::globalValue","pt":"global","to":"changed","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]]},
|
2018-07-11 16:39:34 +02:00
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
changeNode1.context().global.get("globalValue", "meomry", function (err, val) {
|
|
|
|
val.should.equal("changed");
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().global.set("globalValue","changeMe","memory");
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-10-10 12:48:52 +02:00
|
|
|
it('sets the value and type of the message property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t": "set", "p": "payload", "pt": "msg", "to": "12345", "tot": "num" }],"reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal(12345);
|
|
|
|
var t = typeof(msg.payload);
|
|
|
|
t.should.equal("number");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"changeMe"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('sets the value of an already set multi-level message property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"replace","property":"foo.bar","from":"","to":"bar","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.foo.bar.should.equal("bar");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({foo:{bar:"foo"}});
|
2014-10-07 15:46:43 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('sets the value of an empty multi-level message property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"replace","property":"foo.bar","from":"","to":"bar","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.foo.bar.should.equal("bar");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({});
|
2014-10-07 15:46:43 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('sets the value of a message property to another message property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"replace","property":"foo","from":"","to":"msg.fred","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
2015-12-29 23:19:32 +01:00
|
|
|
var rule = helper.getNode("changeNode1").rules[0];
|
|
|
|
rule.t.should.eql('set');
|
|
|
|
rule.tot.should.eql('msg');
|
2014-10-28 12:02:46 +01:00
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.foo.should.equal("bar");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({fred:"bar"});
|
2014-08-14 15:37:27 +02:00
|
|
|
});
|
|
|
|
});
|
2014-10-07 15:46:43 +02:00
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('sets the value of a multi-level message property to another multi-level message property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"replace","property":"foo.bar","from":"","to":"msg.fred.red","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.foo.bar.should.equal("bar");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({fred:{red:"bar"}});
|
2014-10-07 15:46:43 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('doesn\'t set the value of a message property when the \'to\' message property does not exist', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"replace","property":"foo.bar","from":"","to":"msg.fred.red","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
should.not.exist(msg.foo);
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({});
|
2014-10-07 15:46:43 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('overrides the value of a message property when the \'to\' message property does not exist', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"replace","property":"payload","from":"","to":"msg.foo","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
should.not.exist(msg.payload);
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"Hello"});
|
2014-10-07 15:46:43 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('sets the message property to null when the \'to\' message property equals null', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"replace","property":"payload","from":"","to":"msg.foo","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
2016-10-10 14:27:43 +02:00
|
|
|
(msg.payload === null).should.be.true();
|
2014-10-28 12:02:46 +01:00
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"Hello", foo:null});
|
2014-08-14 15:37:27 +02:00
|
|
|
});
|
|
|
|
});
|
2014-10-07 15:46:43 +02:00
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('does not set other properties using = inside to property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"replace","property":"payload","from":"","to":"msg.otherProp=10","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
should.not.exist(msg.payload);
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"changeMe"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('splits dot delimited properties into objects', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"replace","property":"pay.load","from":"","to":"10","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.pay.load.should.equal("10");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({pay:{load:"changeMe"}});
|
2014-08-14 15:37:27 +02:00
|
|
|
});
|
|
|
|
});
|
2015-12-29 23:19:32 +01:00
|
|
|
|
2017-11-17 18:26:36 +01:00
|
|
|
it('changes the value to flow context property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"set","p":"payload","to":"flowValue","tot":"flow"}],"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.eql("Hello World!");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().flow.set("flowValue","Hello World!");
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-11 16:39:34 +02:00
|
|
|
it('changes the value to persistable flow context property', function(done) {
|
2018-07-14 04:00:57 +02:00
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"set","p":"payload","to":"#:(memory0)::flowValue","tot":"flow"}],"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
2018-07-11 16:39:34 +02:00
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.eql("Hello World!");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().flow.set("flowValue","Hello World!","memory",function(err) {
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-11-17 18:26:36 +01:00
|
|
|
it('changes the value to global context property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"set","p":"payload","to":"globalValue","tot":"global"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.eql("Hello World!");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().global.set("globalValue","Hello World!");
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-11 16:39:34 +02:00
|
|
|
it('changes the value to persistable global context property', function(done) {
|
2018-07-14 04:00:57 +02:00
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"set","p":"payload","to":"#:(memory0)::globalValue","tot":"global"}],"name":"changeNode","wires":[["helperNode1"]]},
|
2018-07-11 16:39:34 +02:00
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.eql("Hello World!");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().global.set("globalValue","Hello World!","memory", function (err) {
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-12-29 23:19:32 +01:00
|
|
|
it('changes the value to a number', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"set","p":"payload","to":"123","tot":"num"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.eql(123);
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
2016-04-18 15:38:32 +02:00
|
|
|
|
2017-11-17 18:26:36 +01:00
|
|
|
it('changes the value to a boolean value', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"set","p":"payload","to":"true","tot":"bool"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.eql(true);
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-12-29 23:19:32 +01:00
|
|
|
it('changes the value to a js object', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"set","p":"payload","to":'{"a":123}',"tot":"json"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.eql({a:123});
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-11-17 18:26:36 +01:00
|
|
|
it('changes the value to a buffer object', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"set","p":"payload","to":"[72,101,108,108,111,32,87,111,114,108,100]","tot":"bin"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
var buff = Buffer.from("Hello World");
|
|
|
|
msg.payload.should.eql(buff);
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
2018-05-21 16:10:06 +02:00
|
|
|
|
2016-04-18 15:38:32 +02:00
|
|
|
it('sets the value of the message property to the current timestamp', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","rules":[{"t":"set","p":"ts","pt":"msg","to":"","tot":"date"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
(Date.now() - msg.ts).should.be.approximately(0,50);
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:Date.now()});
|
|
|
|
});
|
|
|
|
});
|
2015-12-29 23:19:32 +01:00
|
|
|
|
2018-05-21 16:10:06 +02:00
|
|
|
describe('env var', function() {
|
|
|
|
before(function() {
|
|
|
|
process.env.NR_TEST_A = 'foo';
|
|
|
|
})
|
|
|
|
after(function() {
|
|
|
|
delete process.env.NR_TEST_A;
|
|
|
|
})
|
|
|
|
it('sets the value using env property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"set","p":"payload","pt":"msg","to":"NR_TEST_A","tot":"env"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("foo");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"123",topic:"ABC"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-11-17 18:26:36 +01:00
|
|
|
it('changes the value using jsonata', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"set","p":"payload","to":"$length(payload)","tot":"jsonata"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.eql(12);
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"Hello World!"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-07 23:23:26 +02:00
|
|
|
it('reports invalid jsonata expression', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"set","p":"payload","to":"$invalid(payload)","tot":"jsonata"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
sinon.spy(changeNode1,"error");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
done("Invalid jsonata expression passed message through");
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"Hello World!"});
|
|
|
|
setTimeout(function() {
|
|
|
|
try {
|
|
|
|
changeNode1.error.called.should.be.true();
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
},50);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-16 11:25:03 +02:00
|
|
|
it('changes the value using flow context with jsonata', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"set","p":"payload","to":"$flowContext(\"foo\")","tot":"jsonata"}],"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[],"z":"flow"},{"id":"flow","type":"tab"}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
initContext(function () {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
changeNode1.context().flow.set("foo","bar");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.eql("bar");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"Hello World!"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('changes the value using global context with jsonata', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"set","p":"payload","to":"$globalContext(\"foo\")","tot":"jsonata"}],"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[],"z":"flow"},{"id":"flow","type":"tab"}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
initContext(function () {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
changeNode1.context().global.set("foo","bar");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.eql("bar");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"Hello World!"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('changes the value using persistable flow context with jsonata', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"set","p":"payload","to":"$flowContext(\"foo\",\"memory1\")","tot":"jsonata"}],"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[],"z":"flow"},{"id":"flow","type":"tab"}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
initContext(function () {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.eql("bar");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().flow.set("foo","bar","memory1",function(err){
|
|
|
|
if(err){
|
|
|
|
done(err);
|
|
|
|
}else{
|
|
|
|
changeNode1.context().flow.set("foo","error!");
|
|
|
|
changeNode1.receive({payload:"Hello World!"});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('changes the value using persistable global context with jsonata', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"set","p":"payload","to":"$globalContext(\"foo\",\"memory1\")","tot":"jsonata"}],"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[],"z":"flow"},{"id":"flow","type":"tab"}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
initContext(function () {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.eql("bar");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().global.set("foo","bar","memory1",function(err){
|
|
|
|
if(err){
|
|
|
|
done(err);
|
|
|
|
}else{
|
|
|
|
changeNode1.context().global.set("foo","error!");
|
|
|
|
changeNode1.receive({payload:"Hello World!"});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-08-14 15:37:27 +02:00
|
|
|
});
|
2014-10-28 12:02:46 +01:00
|
|
|
describe('#change', function() {
|
|
|
|
it('changes the value of the message property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"change","property":"payload","from":"Hello","to":"Goodbye","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("Goodbye World!");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"Hello World!"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-10-10 12:48:52 +02:00
|
|
|
it('changes the value and doesnt change type of the message property for partial match', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t": "change", "p": "payload", "pt": "msg", "from": "123", "fromt": "str", "to": "456", "tot": "num" }],"reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("Change456Me");
|
|
|
|
var t = typeof(msg.payload);
|
|
|
|
t.should.equal("string");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"Change123Me"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('changes the value and type of the message property if a complete match', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t": "change", "p": "payload", "pt": "msg", "from": "123", "fromt": "str", "to": "456", "tot": "num" }],"reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal(456);
|
|
|
|
var t = typeof(msg.payload);
|
|
|
|
t.should.equal("number");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"123"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('changes the value of a multi-level message property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"change","property":"foo.bar","from":"Hello","to":"Goodbye","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.foo.bar.should.equal("Goodbye World!");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({foo:{bar:"Hello World!"}});
|
|
|
|
});
|
|
|
|
});
|
2014-10-07 15:46:43 +02:00
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('sends unaltered message if the changed message property does not exist', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"change","property":"foo","from":"Hello","to":"Goodbye","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
2014-08-14 15:37:27 +02:00
|
|
|
try {
|
2014-10-28 12:02:46 +01:00
|
|
|
msg.payload.should.equal("Hello World!");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
2014-08-14 15:37:27 +02:00
|
|
|
done(err);
|
|
|
|
}
|
2014-10-28 12:02:46 +01:00
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"Hello World!"});
|
|
|
|
});
|
2014-08-14 15:37:27 +02:00
|
|
|
});
|
2014-10-07 15:46:43 +02:00
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('sends unaltered message if a changed multi-level message property does not exist', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"change","property":"foo.bar","from":"Hello","to":"Goodbye","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("Hello World!");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"Hello World!"});
|
2014-08-14 15:37:27 +02:00
|
|
|
});
|
|
|
|
});
|
2014-10-07 15:46:43 +02:00
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('changes the value of the message property based on a regex', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"change","property":"payload","from":"\\d+","to":"NUMBER","reg":true,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("Replace all numbers NUMBER and NUMBER");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"Replace all numbers 12 and 14"});
|
2014-10-07 15:46:43 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('supports regex groups', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"change","property":"payload","from":"(Hello)","to":"$1-$1-$1","reg":true,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("Hello-Hello-Hello World");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"Hello World"});
|
2014-10-07 15:46:43 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-12-29 23:19:32 +01:00
|
|
|
it('reports invalid regex', function(done) {
|
2014-10-28 12:02:46 +01:00
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"change","property":"payload","from":"\\+**+","to":"NUMBER","reg":true,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
2015-03-16 14:58:01 +01:00
|
|
|
var logEvents = helper.log().args.filter(function (evt) {
|
|
|
|
return evt[0].type == "change";
|
|
|
|
});
|
|
|
|
logEvents.should.have.length(1);
|
|
|
|
var msg = logEvents[0][0];
|
|
|
|
msg.should.have.property('level', helper.log().ERROR);
|
|
|
|
msg.should.have.property('id', 'changeNode1');
|
|
|
|
done();
|
2015-03-24 18:35:54 +01:00
|
|
|
|
2014-10-07 15:46:43 +02:00
|
|
|
});
|
|
|
|
});
|
2015-12-29 23:19:32 +01:00
|
|
|
|
|
|
|
it('supports regex groups - new rule format', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"change","p":"payload","from":"(Hello)","to":"$1-$1-$1","fromt":"re","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("Hello-Hello-Hello World");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"Hello World"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('changes the value - new rule format', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"change","p":"payload","from":"ABC","to":"123","fromt":"str","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("abc123abc");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"abcABCabc"});
|
|
|
|
});
|
|
|
|
});
|
2016-03-14 00:10:10 +01:00
|
|
|
|
|
|
|
it('changes the value using msg property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"change","p":"payload","from":"topic","to":"123","fromt":"msg","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("abc123abc");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"abcABCabc",topic:"ABC"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-10-17 23:17:27 +02:00
|
|
|
it('changes the value using flow context property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"change","p":"payload","from":"topic","to":"123","fromt":"flow","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("abc123abc");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().flow.set("topic","ABC");
|
|
|
|
changeNode1.receive({payload:"abcABCabc"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-11 16:39:34 +02:00
|
|
|
it('changes the value using persistable flow context property', function(done) {
|
2018-07-14 04:00:57 +02:00
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"change","p":"payload","from":"#:(memory0)::topic","to":"123","fromt":"flow","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
2018-07-11 16:39:34 +02:00
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("abc123abc");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().flow.set("topic","ABC","memory", function (err) {
|
|
|
|
changeNode1.receive({payload:"abcABCabc"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-10-17 23:17:27 +02:00
|
|
|
it('changes the value using global context property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"change","p":"payload","from":"topic","to":"123","fromt":"global","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("abc123abc");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().global.set("topic","ABC");
|
|
|
|
changeNode1.receive({payload:"abcABCabc"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-11 16:39:34 +02:00
|
|
|
it('changes the value using persistable global context property', function(done) {
|
2018-07-14 04:00:57 +02:00
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"change","p":"payload","from":"#:(memory0)::topic","to":"123","fromt":"global","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]]},
|
2018-07-11 16:39:34 +02:00
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("abc123abc");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().global.set("topic","ABC","memory",function (err) {
|
|
|
|
changeNode1.receive({payload:"abcABCabc"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-11-17 18:26:36 +01:00
|
|
|
it('changes the number using global context property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"change","p":"payload","from":"topic","to":"ABC","fromt":"global","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("ABC");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().global.set("topic",123);
|
|
|
|
changeNode1.receive({payload:123});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-11 16:39:34 +02:00
|
|
|
it('changes the number using persistable global context property', function(done) {
|
2018-07-14 04:00:57 +02:00
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"change","p":"payload","from":"#:(memory0)::topic","to":"ABC","fromt":"global","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]]},
|
2018-07-11 16:39:34 +02:00
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("ABC");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().global.set("topic",123,"memory",function (err) {
|
|
|
|
changeNode1.receive({payload:123});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-03-14 00:10:10 +01:00
|
|
|
it('changes the value using number - string payload', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"change","p":"payload","from":"123","to":"456","fromt":"num","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("456");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"123"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('changes the value using number - number payload', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"change","p":"payload","from":"123","to":"abc","fromt":"num","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("abc");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:123});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('changes the value using boolean - string payload', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"change","p":"payload","from":"true","to":"xxx","fromt":"bool","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("xxx");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"true"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('changes the value using boolean - boolean payload', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"change","p":"payload","from":"true","to":"xxx","fromt":"bool","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("xxx");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:true});
|
|
|
|
});
|
|
|
|
});
|
2017-09-28 11:06:31 +02:00
|
|
|
|
|
|
|
it('changes the value of the global context', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t": "change", "p": "payload", "pt": "global", "from": "Hello", "fromt": "str", "to": "Goodbye", "tot": "str" }],"reg":false,"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[],"z":"flow"}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
helperNode1.context().global.get("payload").should.equal("Goodbye World!");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().global.set("payload","Hello World!");
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-11 16:39:34 +02:00
|
|
|
it('changes the value of the persistable global context', function(done) {
|
2018-07-14 04:00:57 +02:00
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t": "change", "p": "#:(memory0)::payload", "pt": "global", "from": "Hello", "fromt": "str", "to": "Goodbye", "tot": "str" }],"reg":false,"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
2018-07-11 16:39:34 +02:00
|
|
|
{id:"helperNode1", type:"helper", wires:[],"z":"flow"}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
helperNode1.context().global.get("payload","memory", function (err, val) {
|
|
|
|
val.should.equal("Goodbye World!");
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().global.set("payload","Hello World!","memory",function (err) {
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-09-28 11:06:31 +02:00
|
|
|
it('changes the value and doesnt change type of the flow context for partial match', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t": "change", "p": "payload", "pt": "flow", "from": "123", "fromt": "str", "to": "456", "tot": "num" }],"reg":false,"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[],"z":"flow"}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
helperNode1.context().flow.get("payload").should.equal("Change456Me");
|
|
|
|
helperNode1.context().flow.get("payload").should.be.a.String();
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().flow.set("payload","Change123Me");
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-11 16:39:34 +02:00
|
|
|
it('changes the value and doesnt change type of the persistable flow context for partial match', function(done) {
|
2018-07-14 04:00:57 +02:00
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t": "change", "p": "#:(memory0)::payload", "pt": "flow", "from": "123", "fromt": "str", "to": "456", "tot": "num" }],"reg":false,"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
2018-07-11 16:39:34 +02:00
|
|
|
{id:"helperNode1", type:"helper", wires:[],"z":"flow"}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
helperNode1.context().flow.get("payload","memory",function (err, val) {
|
|
|
|
val.should.equal("Change456Me");
|
|
|
|
val.should.be.a.String();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().flow.set("payload","Change123Me","memory",function (err) {
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-09-28 11:06:31 +02:00
|
|
|
it('changes the value and type of the flow context if a complete match', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t": "change", "p": "payload", "pt": "flow", "from": "123", "fromt": "str", "to": "456", "tot": "num" }],"reg":false,"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[],"z":"flow"}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
helperNode1.context().flow.get("payload").should.equal(456);
|
|
|
|
helperNode1.context().flow.get("payload").should.be.a.Number();
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().flow.set("payload","123");
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-12 09:26:16 +02:00
|
|
|
it('changes the value and type of the persistable flow context if a complete match', function(done) {
|
2018-07-14 04:00:57 +02:00
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t": "change", "p": "#:(memory0)::payload", "pt": "flow", "from": "123", "fromt": "str", "to": "456", "tot": "num" }],"reg":false,"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
2018-07-11 16:39:34 +02:00
|
|
|
{id:"helperNode1", type:"helper", wires:[],"z":"flow"}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
helperNode1.context().flow.get("payload").should.equal(456);
|
|
|
|
helperNode1.context().flow.get("payload").should.be.a.Number();
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().flow.set("payload","123","memory",function (err) {
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-09-28 11:06:31 +02:00
|
|
|
it('changes the value using number - number flow context', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t": "change", "p": "payload", "pt": "flow", "from": "123", "fromt": "num", "to": "abc", "tot": "str" }],"reg":false,"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[],"z":"flow"}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
helperNode1.context().flow.get("payload").should.equal("abc");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().flow.set("payload",123);
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-11 16:39:34 +02:00
|
|
|
it('changes the value using number - number persistable flow context', function(done) {
|
2018-07-14 04:00:57 +02:00
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t": "change", "p": "#:(memory0)::payload", "pt": "flow", "from": "123", "fromt": "num", "to": "abc", "tot": "str" }],"reg":false,"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
2018-07-11 16:39:34 +02:00
|
|
|
{id:"helperNode1", type:"helper", wires:[],"z":"flow"}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
helperNode1.context().flow.get("payload","memory",function (err, val) {
|
|
|
|
val.should.equal("abc");
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().flow.set("payload",123,"memory",function (err) {
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-09-28 11:06:31 +02:00
|
|
|
it('changes the value using boolean - boolean flow context', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t": "change", "p": "payload", "pt": "flow", "from": "true", "fromt": "bool", "to": "abc", "tot": "str" }],"reg":false,"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[],"z":"flow"}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
helperNode1.context().flow.get("payload").should.equal("abc");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().flow.set("payload",true);
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
2018-05-21 16:10:06 +02:00
|
|
|
|
2018-07-11 16:39:34 +02:00
|
|
|
it('changes the value using boolean - boolean persistable flow context', function(done) {
|
2018-07-14 04:00:57 +02:00
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t": "change", "p": "#:(memory0)::payload", "pt": "flow", "from": "true", "fromt": "bool", "to": "abc", "tot": "str" }],"reg":false,"name":"changeNode","wires":[["helperNode1"]],"z":"flow"},
|
2018-07-11 16:39:34 +02:00
|
|
|
{id:"helperNode1", type:"helper", wires:[],"z":"flow"}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
helperNode1.context().flow.get("payload","memory",function (err, val) {
|
|
|
|
val.should.equal("abc");
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().flow.set("payload",true,function (err) {
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-05-21 16:10:06 +02:00
|
|
|
describe('env var', function() {
|
|
|
|
before(function() {
|
|
|
|
process.env.NR_TEST_A = 'foo';
|
|
|
|
})
|
|
|
|
after(function() {
|
|
|
|
delete process.env.NR_TEST_A;
|
|
|
|
})
|
|
|
|
it('changes the value using env property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"change","p":"payload","from":"topic","to":"NR_TEST_A","fromt":"msg","tot":"env"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("abcfooabc");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"abcABCabc",topic:"ABC"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-10-07 15:46:43 +02:00
|
|
|
});
|
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
describe("#delete", function() {
|
|
|
|
it('deletes the value of the message property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"delete","property":"payload","from":"","to":"","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.should.not.have.property('payload');
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"This won't get through!"});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-11-17 18:26:36 +01:00
|
|
|
it('deletes the value of global context property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t": "delete", "p": "globalValue", "pt": "global"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
changeNode1.context().global.should.not.have.property("globalValue");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().global.set("globalValue","Hello World!");
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-11 16:39:34 +02:00
|
|
|
it('deletes the value of persistable global context property', function(done) {
|
2018-07-14 04:00:57 +02:00
|
|
|
var flow = [{"id":"changeNode1","type":"change",rules:[{ "t": "delete", "p": "#:(memory0)::globalValue", "pt": "global"}],"name":"changeNode","wires":[["helperNode1"]]},
|
2018-07-11 16:39:34 +02:00
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
changeNode1.context().global.get("globalValue","memory",function(err,val) {
|
|
|
|
should.equal(undefined);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.context().global.set("globalValue","Hello World!","memory",function (err) {
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('deletes the value of a multi-level message property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"delete","property":"foo.bar","from":"","to":"","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.should.not.have.property('foo.bar');
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"This won't get through!", foo:{bar:"This will be deleted!"}});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('sends unaltered message if the deleted message property does not exist', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"delete","property":"foo","from":"","to":"","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.should.not.have.property('foo');
|
|
|
|
msg.payload.should.equal('payload');
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"payload"});
|
|
|
|
});
|
|
|
|
});
|
2014-10-07 15:46:43 +02:00
|
|
|
|
2014-10-28 12:02:46 +01:00
|
|
|
it('sends unaltered message if a deleted multi-level message property does not exist', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","action":"delete","property":"foo.bar","from":"","to":"","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.should.not.have.property('foo.bar');
|
|
|
|
msg.payload.should.equal('payload');
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"payload"});
|
2014-08-14 15:37:27 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2015-03-24 18:35:54 +01:00
|
|
|
|
2016-04-10 16:55:05 +02:00
|
|
|
describe("#move", function() {
|
|
|
|
it('moves the value of the message property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","rules":[{"t":"move","p":"topic","pt":"msg","to":"payload","tot":"msg"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.should.not.have.property('topic');
|
|
|
|
msg.should.have.property('payload');
|
|
|
|
msg.payload.should.equal("You've got to move it move it.");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({topic:"You've got to move it move it.", payload:{foo:"bar"}});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('moves the value of a message property object', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","rules":[{"t":"move","p":"topic","pt":"msg","to":"payload","tot":"msg"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.should.not.have.property('topic');
|
|
|
|
msg.should.have.property('payload');
|
|
|
|
msg.payload.should.have.property('foo');
|
|
|
|
msg.payload.foo.should.have.property('bar');
|
|
|
|
msg.payload.foo.bar.should.equal(1);
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({topic:{foo:{bar:1}}, payload:"String"});
|
|
|
|
});
|
|
|
|
});
|
2016-08-28 13:09:37 +02:00
|
|
|
it('moves the value of a message property object to a sub-property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.foo","tot":"msg"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.should.have.property('payload');
|
|
|
|
msg.payload.should.have.property('foo');
|
|
|
|
msg.payload.foo.should.equal("bar");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:"bar"});
|
|
|
|
});
|
|
|
|
});
|
2016-10-10 12:10:36 +02:00
|
|
|
it('moves the value of a message sub-property object to a property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","rules":[{"t":"move","p":"payload.foo","pt":"msg","to":"payload","tot":"msg"}],"name":"changeNode","wires":[["helperNode1"]]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.should.have.property('payload');
|
|
|
|
msg.payload.should.equal("bar");
|
|
|
|
(typeof msg.payload).should.equal("string");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({payload:{foo:"bar"}});
|
|
|
|
});
|
|
|
|
});
|
2016-04-10 16:55:05 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('- multiple rules', function() {
|
2015-03-18 17:20:21 +01:00
|
|
|
it('handles multiple rules', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","wires":[["helperNode1"]],
|
|
|
|
rules:[
|
|
|
|
{t:"set",p:"payload",to:"newValue"},
|
|
|
|
{t:"change",p:"changeProperty",from:"this",to:"that"},
|
|
|
|
{t:"delete",p:"deleteProperty"}
|
|
|
|
]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("newValue");
|
|
|
|
msg.changeProperty.should.equal("change that value");
|
|
|
|
should.not.exist(msg.deleteProperty);
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({
|
|
|
|
payload:"changeMe",
|
|
|
|
changeProperty:"change this value",
|
|
|
|
deleteProperty:"delete this value"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-07-16 11:25:03 +02:00
|
|
|
|
2015-03-18 17:20:21 +01:00
|
|
|
it('applies multiple rules in order', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1","type":"change","wires":[["helperNode1"]],
|
|
|
|
rules:[
|
|
|
|
{t:"set",p:"payload",to:"a this (hi)"},
|
|
|
|
{t:"change",p:"payload",from:"this",to:"that"},
|
|
|
|
{t:"change",p:"payload",from:"\\(.*\\)",to:"[new]",re:true},
|
|
|
|
]},
|
|
|
|
{id:"helperNode1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.payload.should.equal("a that [new]");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeNode1.receive({
|
|
|
|
payload:"changeMe"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-07-14 04:00:57 +02:00
|
|
|
|
|
|
|
it('can access two persistable flow context property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1", "z":"t1", "type":"change",
|
|
|
|
"wires":[["helperNode1"]],
|
|
|
|
rules:[
|
|
|
|
{"t":"set", "p":"val0", "to":"#:(memory0)::val", "tot":"flow"},
|
|
|
|
{"t":"set", "p":"val1", "to":"#:(memory1)::val", "tot":"flow"}
|
|
|
|
]},
|
|
|
|
{id:"helperNode1", "z":"t1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
initContext(function () {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.should.have.property("val0", "foo");
|
|
|
|
msg.should.have.property("val1", "bar");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var flow = changeNode1.context().flow;
|
|
|
|
flow.set("val", "foo", "memory0", function (err) {
|
|
|
|
flow.set("val", "bar", "memory1", function (err) {
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-07-16 11:25:03 +02:00
|
|
|
|
2018-07-14 04:00:57 +02:00
|
|
|
it('can access two persistable global context property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1", "z":"t1", "type":"change",
|
|
|
|
"wires":[["helperNode1"]],
|
|
|
|
rules:[
|
|
|
|
{"t":"set", "p":"val0", "to":"#:(memory0)::val", "tot":"global"},
|
|
|
|
{"t":"set", "p":"val1", "to":"#:(memory1)::val", "tot":"global"}
|
|
|
|
]},
|
|
|
|
{id:"helperNode1", "z":"t1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
initContext(function () {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.should.have.property("val0", "foo");
|
|
|
|
msg.should.have.property("val1", "bar");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var global = changeNode1.context().global;
|
|
|
|
global.set("val", "foo", "memory0", function (err) {
|
|
|
|
global.set("val", "bar", "memory1", function (err) {
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-07-16 11:25:03 +02:00
|
|
|
|
2018-07-14 04:00:57 +02:00
|
|
|
it('can access persistable global & flow context property', function(done) {
|
|
|
|
var flow = [{"id":"changeNode1", "z":"t1", "type":"change",
|
|
|
|
"wires":[["helperNode1"]],
|
|
|
|
rules:[
|
|
|
|
{"t":"set", "p":"val0", "to":"#:(memory0)::val", "tot":"flow"},
|
|
|
|
{"t":"set", "p":"val1", "to":"#:(memory1)::val", "tot":"global"}
|
|
|
|
]},
|
|
|
|
{id:"helperNode1", "z":"t1", type:"helper", wires:[]}];
|
|
|
|
helper.load(changeNode, flow, function() {
|
|
|
|
initContext(function () {
|
|
|
|
var changeNode1 = helper.getNode("changeNode1");
|
|
|
|
var helperNode1 = helper.getNode("helperNode1");
|
|
|
|
helperNode1.on("input", function(msg) {
|
|
|
|
try {
|
|
|
|
msg.should.have.property("val0", "foo");
|
|
|
|
msg.should.have.property("val1", "bar");
|
|
|
|
done();
|
|
|
|
} catch(err) {
|
|
|
|
done(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var context = changeNode1.context();
|
|
|
|
var flow = context.flow;
|
|
|
|
var global = context.global;
|
|
|
|
flow.set("val", "foo", "memory0", function (err) {
|
|
|
|
global.set("val", "bar", "memory1", function (err) {
|
|
|
|
changeNode1.receive({payload:""});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-07-16 11:25:03 +02:00
|
|
|
|
2015-03-24 18:35:54 +01:00
|
|
|
});
|
|
|
|
});
|