From f8dd68ecc4ac0260b248ceebfeb47bd2128aa62d Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Fri, 7 Jun 2019 21:35:36 +0900 Subject: [PATCH] Add support for env var propety in switch node --- .../@node-red/nodes/core/logic/10-switch.html | 2 +- test/nodes/core/logic/10-switch_spec.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/nodes/core/logic/10-switch.html b/packages/node_modules/@node-red/nodes/core/logic/10-switch.html index 45ee7a8ad..fa3046c0f 100644 --- a/packages/node_modules/@node-red/nodes/core/logic/10-switch.html +++ b/packages/node_modules/@node-red/nodes/core/logic/10-switch.html @@ -128,7 +128,7 @@ var node = this; var previousValueType = {value:"prev",label:this._("inject.previous"),hasValue:false}; - $("#node-input-property").typedInput({default:this.propertyType||'msg',types:['msg','flow','global','jsonata']}); + $("#node-input-property").typedInput({default:this.propertyType||'msg',types:['msg','flow','global','jsonata','env']}); var outputCount = $("#node-input-outputs").val("{}"); var andLabel = this._("switch.and"); diff --git a/test/nodes/core/logic/10-switch_spec.js b/test/nodes/core/logic/10-switch_spec.js index b33f436fc..899e6edef 100644 --- a/test/nodes/core/logic/10-switch_spec.js +++ b/test/nodes/core/logic/10-switch_spec.js @@ -818,6 +818,14 @@ describe('switch Node', function() { }); }); + it('should handle env var expression', function(done) { + var flow = [{id:"switchNode1",type:"switch",name:"switchNode",property:"VAR",propertyType:"env",rules:[{"t":"eq","v":"VAL"}],checkall:true,outputs:1,wires:[["helperNode1"]]}, + {id:"helperNode1", type:"helper", wires:[]}]; + process.env.VAR = "VAL"; + customFlowSwitchTest(flow, true, "OK", done); + }); + + it('should take head of message sequence (no repair)', function(done) { var flow = [{id:"switchNode1",type:"switch",name:"switchNode",property:"payload",rules:[{"t":"head","v":3}],checkall:false,repair:false,outputs:1,wires:[["helperNode1"]]}, {id:"helperNode1", type:"helper", wires:[]}];