From 18f8dde7120e31bfe16897967832df2b4f22124d Mon Sep 17 00:00:00 2001 From: dxdc Date: Wed, 27 May 2020 23:47:04 -0500 Subject: [PATCH] Add test for $moment jsonata expression --- test/unit/@node-red/util/lib/util_spec.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/unit/@node-red/util/lib/util_spec.js b/test/unit/@node-red/util/lib/util_spec.js index 261dbc531..653342777 100644 --- a/test/unit/@node-red/util/lib/util_spec.js +++ b/test/unit/@node-red/util/lib/util_spec.js @@ -505,6 +505,11 @@ describe("@node-red/util/util", function() { var result = util.evaluateJSONataExpression(expr,{}); result.should.eql('foo'); }); + it('accesses moment from an expression', function() { + var expr = util.prepareJSONataExpression('$moment("2020-05-27", "YYYY-MM-DD").add("days", 7).add("months", 1).format("YYYY-MM-DD")',{}); + var result = util.evaluateJSONataExpression(expr,{}); + result.should.eql('2020-07-03'); + }); it('handles non-existant flow context variable', function() { var expr = util.prepareJSONataExpression('$flowContext("nonExistant")',{context:function() { return {flow:{get: function(key) { return {'foo':'bar'}[key]}}}}}); var result = util.evaluateJSONataExpression(expr,{payload:"hello"});