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

Change node must handle empty rule set

This commit is contained in:
Nick O'Leary 2018-08-16 09:41:43 +01:00
parent 042409f870
commit 72c400794c
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 21 additions and 0 deletions

View File

@ -283,6 +283,9 @@ module.exports = function(RED) {
} }
} }
function applyRules(msg, currentRule) { function applyRules(msg, currentRule) {
if (currentRule >= node.rules.length) {
return Promise.resolve(msg);
}
var r = node.rules[currentRule]; var r = node.rules[currentRule];
var rulePromise; var rulePromise;
if (r.t === "move") { if (r.t === "move") {

View File

@ -78,6 +78,24 @@ describe('change Node', function() {
done(); done();
}); });
}); });
it('should no-op if there are no rules', function(done) {
var flow = [{"id":"changeNode1","type":"change","rules":[],"action":"","property":"","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.eql(sentMsg);
done();
} catch(err) {
done(err);
}
});
var sentMsg = {payload:"leaveMeAlong"};
changeNode1.receive(sentMsg);
});
});
describe('#set' , function() { describe('#set' , function() {