mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge pull request #2226 from node-red/add-has_key-to-switch
Add "has key" rule to switch node + tests
This commit is contained in:
@@ -254,6 +254,16 @@ describe('switch Node', function() {
|
||||
genericSwitchTest("gte", 3, true, true, 3, done);
|
||||
});
|
||||
|
||||
it('should match if a payload has a required property', function(done) {
|
||||
genericSwitchTest("hask", "a", true, true, {a:1}, done);
|
||||
});
|
||||
it('should not match if a payload does not have a required property', function(done) {
|
||||
genericSwitchTest("hask", "a", true, false, {b:1}, done);
|
||||
});
|
||||
it('should not match if the key is not a string', function(done) {
|
||||
genericSwitchTest("hask", 1, true, false, {a:1}, done);
|
||||
});
|
||||
|
||||
it('should check if payload is between given values', function(done) {
|
||||
twoFieldSwitchTest("btwn", "3", "5", true, true, 4, done);
|
||||
});
|
||||
@@ -519,7 +529,6 @@ describe('switch Node', function() {
|
||||
singularSwitchTest("nempty", true, false, 0, done);
|
||||
});
|
||||
|
||||
|
||||
it('should check input against a previous value', function(done) {
|
||||
var flow = [{id:"switchNode1",type:"switch",name:"switchNode",property:"payload",rules:[{ "t": "gt", "v": "", "vt": "prev" }],checkall:true,outputs:1,wires:[["helperNode1"]]},
|
||||
{id:"helperNode1", type:"helper", wires:[]}];
|
||||
|
Reference in New Issue
Block a user