update according to comments

This commit is contained in:
Hiroyasu Nishiyama
2020-05-11 14:37:14 +09:00
parent c649e1b4a2
commit 5b197adf33
7 changed files with 69 additions and 29 deletions

View File

@@ -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() {