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

Improve timings in trigger node test

This commit is contained in:
Nick O'Leary 2020-09-25 23:32:59 +01:00
parent 91c2f479bb
commit 1a4d720978
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -645,30 +645,39 @@ describe('trigger node', function() {
}); });
it('should be able to reset correctly having not output anything on second edge', function(done) { it('should be able to reset correctly having not output anything on second edge', function(done) {
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", op2type:"nul", op1:"true",op1type:"val", op2:"false", duration:"35", wires:[["n2"]] }, var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", op2type:"nul", op1:"true",op1type:"val", op2:"false", duration:"100", wires:[["n2"]] },
{id:"n2", type:"helper"} ]; {id:"n2", type:"helper"} ];
helper.load(triggerNode, flow, function() { helper.load(triggerNode, flow, function() {
var n1 = helper.getNode("n1"); var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2"); var n2 = helper.getNode("n2");
var c = 0; var c = 0;
var errors = [];
n2.on("input", function(msg) { n2.on("input", function(msg) {
try { try {
msg.should.have.a.property("topic", "pass")
msg.should.have.a.property("payload", true); msg.should.have.a.property("payload", true);
c += 1; c += 1;
} }
catch(err) { done(err); } catch(err) { errors.push(err) }
}); });
setTimeout( function() { setTimeout( function() {
c.should.equal(3); // should only have had one output. if (errors.length > 0) {
done(); done(errors[0])
},300); } else {
n1.emit("input", {payload:1}); c.should.equal(2);
done();
}
},350);
n1.emit("input", {payload:1, topic:"pass"});
setTimeout( function() { setTimeout( function() {
n1.emit("input", {payload:2}); n1.emit("input", {payload:2, topic:"should-block"});
},100); },50);
setTimeout( function() { setTimeout( function() {
n1.emit("input", {payload:3}); n1.emit("input", {payload:3, topic:"pass"});
},200); },200);
setTimeout( function() {
n1.emit("input", {payload:2, topic:"should-block"});
},250);
}); });
}); });