mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add async mode to evaluateJSONataExpression
This commit is contained in:
@@ -458,6 +458,30 @@ describe("red/util", function() {
|
||||
var result = util.evaluateJSONataExpression(expr,{payload:"hello"});
|
||||
should.not.exist(result);
|
||||
});
|
||||
it('handles async flow context access', function(done) {
|
||||
var expr = util.prepareJSONataExpression('$flowContext("foo")',{context:function() { return {flow:{get: function(key,callback) { setTimeout(()=>{callback(null,{'foo':'bar'}[key])},10)}}}}});
|
||||
util.evaluateJSONataExpression(expr,{payload:"hello"},function(err,value) {
|
||||
try {
|
||||
should.not.exist(err);
|
||||
value.should.eql("bar");
|
||||
done();
|
||||
} catch(err2) {
|
||||
done(err2);
|
||||
}
|
||||
});
|
||||
})
|
||||
it('handles async global context access', function(done) {
|
||||
var expr = util.prepareJSONataExpression('$globalContext("foo")',{context:function() { return {global:{get: function(key,callback) { setTimeout(()=>{callback(null,{'foo':'bar'}[key])},10)}}}}});
|
||||
util.evaluateJSONataExpression(expr,{payload:"hello"},function(err,value) {
|
||||
try {
|
||||
should.not.exist(err);
|
||||
value.should.eql("bar");
|
||||
done();
|
||||
} catch(err2) {
|
||||
done(err2);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user