Skip to content

Commit

Permalink
make trigger test a bit more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Conway-Jones committed Mar 19, 2018
1 parent 5d54ca7 commit 7e41679
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions test/nodes/core/core/89-trigger_spec.js
Expand Up @@ -450,32 +450,26 @@ describe('trigger node', function() {
});
});

it('should be able to extend the delay and output the 2nd payload', function(done) {
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", extend:"true", op1type:"nul", op2type:"payl", op1:"false", op2:"true", duration:"50", wires:[["n2"]] },
it('should be able to extend the delay and output the most recent payload', function(done) {
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", extend:"true", op1type:"nul", op2type:"payl", op1:"false", op2:"true", duration:"60", wires:[["n2"]] },
{id:"n2", type:"helper"} ];
helper.load(triggerNode, flow, function() {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
var c = 0;
n2.on("input", function(msg) {
try {
if (c === 0) {
msg.should.have.a.property("payload", "Goodbye");
c += 1;
}
else {
msg.should.have.a.property("payload", "World");
(Date.now() - ss).should.be.greaterThan(70);
done();
}
msg.should.have.a.property("payload", "World");
(Date.now() - ss).should.be.greaterThan(120);
done();
}
catch(err) { done(err); }
});
var ss = Date.now();
n1.emit("input", {payload:"Hello"});
setTimeout( function() {
n1.emit("input", {payload:"Goodbye"});
},20);
},40);
setTimeout( function() {
n1.emit("input", {payload:"World"});
},80);
Expand Down

0 comments on commit 7e41679

Please sign in to comment.