Fix the test cases which sometimes fails due to timing. (#1228)

This commit is contained in:
Kazuki-Nakanishi 2017-04-13 04:54:31 +09:00 committed by Nick O'Leary
parent c54cf26848
commit 05878d3176
3 changed files with 15 additions and 13 deletions

View File

@ -463,16 +463,16 @@ describe('delay Node', function() {
try {
if (msg.topic === "_none_") {
msg.payload.should.equal(2);
(Date.now() - t).should.be.approximately(500,50);
(Date.now() - t).should.be.approximately(500,200);
}
else if (msg.topic === "A") {
msg.payload.should.equal(4);
(Date.now() - t).should.be.approximately(750,50);
(Date.now() - t).should.be.approximately(750,200);
}
else {
msg.topic.should.equal("B");
msg.payload.should.equal(1);
(Date.now() - t).should.be.approximately(1000,50);
(Date.now() - t).should.be.approximately(1000,200);
done();
}
} catch(e) {
@ -506,16 +506,16 @@ describe('delay Node', function() {
try {
if (msg.topic === "_none_") {
msg.payload.should.equal(2);
(Date.now() - t).should.be.approximately(500,50);
(Date.now() - t).should.be.approximately(500,200);
}
else if (msg.topic === "A") {
msg.payload.should.equal(4);
(Date.now() - t).should.be.approximately(500,50);
(Date.now() - t).should.be.approximately(500,200);
}
else {
msg.topic.should.equal("B");
msg.payload.should.equal(1);
(Date.now() - t).should.be.approximately(500,50);
(Date.now() - t).should.be.approximately(500,200);
done();
}
} catch(e) {

View File

@ -415,7 +415,7 @@ describe('trigger node', function() {
n1.emit("input", {reset:true}); // reset
},90);
setTimeout( function() {
c.should.equalOneOf(3,4); // should send foo 3 or 4 times.
c.should.within(2,5); // should send foo between 2 and 5 times.
done();
},180);
});

View File

@ -134,12 +134,14 @@ describe('LocalFileSystem', function() {
fs.existsSync(flowFileBackupPath).should.be.false();
fs.writeFileSync(flowFileBackupPath,JSON.stringify(testFlow));
fs.existsSync(flowFileBackupPath).should.be.true();
localfilesystem.getFlows().then(function(flows) {
flows.should.eql(testFlow);
done();
}).otherwise(function(err) {
done(err);
});
setTimeout(function() {
localfilesystem.getFlows().then(function(flows) {
flows.should.eql(testFlow);
done();
}).otherwise(function(err) {
done(err);
});
},50);
}).otherwise(function(err) {
done(err);
});