mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
update according to comments
This commit is contained in:
@@ -1349,6 +1349,20 @@ describe('function node', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should wait completion of initialization', function(done) {
|
||||
var flow = [{id:"n1",type:"function",wires:[["n2"]],func:"msg.payload = global.get('X'); return msg;",initialize:"global.set('X', '-'); return new Promise((resolve, reject) => setTimeout(() => { global.set('X','bar'); resolve(); }, 500));"},
|
||||
{id:"n2", type:"helper"}];
|
||||
helper.load(functionNode, flow, function() {
|
||||
var n1 = helper.getNode("n1");
|
||||
var n2 = helper.getNode("n2");
|
||||
n2.on("input", function(msg) {
|
||||
msg.should.have.property("payload", "bar");
|
||||
done();
|
||||
});
|
||||
n1.receive({payload: "foo"});
|
||||
});
|
||||
});
|
||||
|
||||
it('should execute finalization', function(done) {
|
||||
var flow = [{id:"n1",type:"function",wires:[],func:"return msg;",finalize:"global.set('X','bar');"}];
|
||||
helper.load(functionNode, flow, function() {
|
||||
|
Reference in New Issue
Block a user