mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fix Switch node handling of hasKey rule when property is undefined
This commit is contained in:
parent
393290df2c
commit
8da00c0872
@ -72,7 +72,7 @@ module.exports = function(RED) {
|
|||||||
return ((min <= index) && (index <= max));
|
return ((min <= index) && (index <= max));
|
||||||
},
|
},
|
||||||
'hask': function(a, b) {
|
'hask': function(a, b) {
|
||||||
return (typeof b !== "object" ) && a.hasOwnProperty(b+"");
|
return a !== undefined && a !== null && (typeof b !== "object" ) && a.hasOwnProperty(b+"");
|
||||||
},
|
},
|
||||||
'jsonata_exp': function(a, b) { return (b === true); },
|
'jsonata_exp': function(a, b) { return (b === true); },
|
||||||
'else': function(a) { return a === true; }
|
'else': function(a) { return a === true; }
|
||||||
|
@ -267,7 +267,12 @@ describe('switch Node', function() {
|
|||||||
it('should not match if the key is not a string', function(done) {
|
it('should not match if the key is not a string', function(done) {
|
||||||
genericSwitchTest("hask", 1, true, false, {a:1}, done);
|
genericSwitchTest("hask", 1, true, false, {a:1}, done);
|
||||||
});
|
});
|
||||||
|
it('should not match if the parent object does not exist - null', function(done) {
|
||||||
|
genericSwitchTest("hask", "a", true, false, null, done);
|
||||||
|
});
|
||||||
|
it('should not match if the parent object does not exist - undefined', function(done) {
|
||||||
|
genericSwitchTest("hask", "a", true, false, undefined, done);
|
||||||
|
});
|
||||||
it('should check if payload is between given values', function(done) {
|
it('should check if payload is between given values', function(done) {
|
||||||
twoFieldSwitchTest("btwn", "3", "5", true, true, 4, done);
|
twoFieldSwitchTest("btwn", "3", "5", true, true, 4, done);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user