Skip to content

Commit

Permalink
Check timezone output as well as hours. Also, using notEquals rather …
Browse files Browse the repository at this point in the history
…than ok on tests.

Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
  • Loading branch information
ncb000gt committed Apr 22, 2012
1 parent 4607cc2 commit 07834aa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/test-cron.js
Expand Up @@ -205,7 +205,7 @@ module.exports = testCase({
}
},
'test a job with a string and a given time zone': function (assert) {
assert.expect(2);
assert.expect(3);

var time = require("time");
var zone = "America/Chicago";
Expand All @@ -216,13 +216,15 @@ module.exports = testCase({

// Current time
t = new time.Date();
t.setTimezone("America/New_York");

// If current time is New Orleans time, switch to Los Angeles..
if (t.getHours() === d.getHours()) {
zone = "America/Los_Angeles";
d.setTimezone(zone);
}
assert.ok(d.getHours() !== t.getHours());
assert.notEqual(d.getHours(), t.getHours());
assert.notEqual(d.getTimezone(), t.getTimezone());

var seconds = d.getSeconds() + 1;
var c = new cron.CronJob(seconds + ' ' + d.getMinutes() + ' ' + d.getHours() + ' * * *', function(){
Expand All @@ -246,13 +248,14 @@ module.exports = testCase({

// Current time
t = new time.Date();
t.setTimezone("America/New_York");

// If current time is New Orleans time, switch to Los Angeles..
if (t.getHours() === d.getHours()) {
zone = "America/Los_Angeles";
d.setTimezone(zone);
}
assert.ok(d.getHours() !== t.getHours());
assert.notEqual(d.getHours(), t.getHours());

if ((58 - t.getSeconds()) <= 0) {
setTimeout(testRun, (60000 - (t.getSeconds()*1000)) + 1000);
Expand Down

0 comments on commit 07834aa

Please sign in to comment.