Let switch node between rule work both ways round

and add test
This commit is contained in:
Dave Conway-Jones 2019-10-02 09:52:26 +01:00
parent af742ea536
commit b763e0b0cb
No known key found for this signature in database
GPG Key ID: 302A6725C594817F
2 changed files with 6 additions and 2 deletions

View File

@ -24,7 +24,7 @@ module.exports = function(RED) {
'lte': function(a, b) { return a <= b; },
'gt': function(a, b) { return a > b; },
'gte': function(a, b) { return a >= b; },
'btwn': function(a, b, c) { return a >= b && a <= c; },
'btwn': function(a, b, c) { return (a >= b && a <= c) || (a <= b && a >= c); },
'cont': function(a, b) { return (a + "").indexOf(b) != -1; },
'regex': function(a, b, c, d) { return (a + "").match(new RegExp(b,d?'i':'')); },
'true': function(a) { return a === true; },

View File

@ -268,6 +268,10 @@ describe('switch Node', function() {
twoFieldSwitchTest("btwn", "3", "5", true, true, 4, done);
});
it('should check if payload is between given values in "wrong" order', function(done) {
twoFieldSwitchTest("btwn", "5", "3", true, true, 4, done);
});
it('should check if payload is between given string values', function(done) {
twoFieldSwitchTest("btwn", "c", "e", true, true, "d", done);
});
@ -585,7 +589,7 @@ describe('switch Node', function() {
done(err);
}
} else {
done();
//done();
}
});
switchNode1.receive({payload:0});