1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add test for $moment jsonata expression

This commit is contained in:
dxdc 2020-05-27 23:47:04 -05:00 committed by GitHub
parent effff3405b
commit 18f8dde712
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -505,6 +505,11 @@ describe("@node-red/util/util", function() {
var result = util.evaluateJSONataExpression(expr,{}); var result = util.evaluateJSONataExpression(expr,{});
result.should.eql('foo'); 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() { 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 expr = util.prepareJSONataExpression('$flowContext("nonExistant")',{context:function() { return {flow:{get: function(key) { return {'foo':'bar'}[key]}}}}});
var result = util.evaluateJSONataExpression(expr,{payload:"hello"}); var result = util.evaluateJSONataExpression(expr,{payload:"hello"});