mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
make trigger test a bit more robust
This commit is contained in:
parent
5d54ca7477
commit
7e416797e9
@ -450,8 +450,8 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to extend the delay and output the 2nd payload', function(done) {
|
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:"50", wires:[["n2"]] },
|
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"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
@ -459,23 +459,17 @@ describe('trigger node', function() {
|
|||||||
var c = 0;
|
var c = 0;
|
||||||
n2.on("input", function(msg) {
|
n2.on("input", function(msg) {
|
||||||
try {
|
try {
|
||||||
if (c === 0) {
|
|
||||||
msg.should.have.a.property("payload", "Goodbye");
|
|
||||||
c += 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
msg.should.have.a.property("payload", "World");
|
msg.should.have.a.property("payload", "World");
|
||||||
(Date.now() - ss).should.be.greaterThan(70);
|
(Date.now() - ss).should.be.greaterThan(120);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch(err) { done(err); }
|
catch(err) { done(err); }
|
||||||
});
|
});
|
||||||
var ss = Date.now();
|
var ss = Date.now();
|
||||||
n1.emit("input", {payload:"Hello"});
|
n1.emit("input", {payload:"Hello"});
|
||||||
setTimeout( function() {
|
setTimeout( function() {
|
||||||
n1.emit("input", {payload:"Goodbye"});
|
n1.emit("input", {payload:"Goodbye"});
|
||||||
},20);
|
},40);
|
||||||
setTimeout( function() {
|
setTimeout( function() {
|
||||||
n1.emit("input", {payload:"World"});
|
n1.emit("input", {payload:"World"});
|
||||||
},80);
|
},80);
|
||||||
|
Loading…
Reference in New Issue
Block a user