Skip to content
Browse files

Take approach suggested by ncb000gt for avoiding minute boundary. htt…

  • Loading branch information...
1 parent 7102fdb commit 8205bc756e02ee8be04b555bfb9de707b192e2a5 @danhbear committed Jul 25, 2012
Showing with 18 additions and 11 deletions.
  1. +18 −11 tests/test-cron.js
View
29 tests/test-cron.js
@@ -35,17 +35,24 @@ module.exports = testCase({
}, 5250);
},
'test standard cron no-seconds syntax doesnt send on seconds (* * * * *)': function(assert) {
- assert.expect(1);
- var called = 0;
- var c = new cron.CronJob('* * * * *', function() {
- called++;
- }, null, true);
- setTimeout(function() {
- c.stop();
- // Note that it could be called once if the test lands on a minute boundary
- assert.ok(called <= 1);
- assert.done();
- }, 5250);
+ assert.expect(0);
+ // Delay test from running at minute boundary
+ var prepDate = new Date();
+ if (prepDate.getSeconds() >= 55) {
+ setTimeout(testRun, 5000);
+ } else {
+ testRun();
+ }
+
+ function testRun() {
+ var c = new cron.CronJob('* * * * *', function() {
+ assert.ok(true);
+ }, null, true);
+ setTimeout(function() {
+ c.stop();
+ assert.done();
+ }, 5250);
+ }
},
'test every second for 5 seconds with oncomplete (* * * * * *)': function(assert) {
assert.expect(6);

0 comments on commit 8205bc7

Please sign in to comment.
Something went wrong with that request. Please try again.