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

View File

@ -415,7 +415,7 @@ describe('trigger node', function() {
n1.emit("input", {reset:true}); // reset n1.emit("input", {reset:true}); // reset
},90); },90);
setTimeout( function() { 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(); done();
},180); },180);
}); });

View File

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