8000
We read every piece of feedback, and take your input very seriously.
1 parent 1c6ad5b commit 5ad27dfCopy full SHA for 5ad27df
tests/test-cron.js
@@ -236,6 +236,44 @@ module.exports = testCase({
236
clock.restore();
237
job.stop();
238
},
239
+ 'test a job with a string and a given time zone': function (assert) {
240
+ var clock = sinon.useFakeTimers();
241
+
242
+ assert.expect(2);
243
244
+ var moment = require("moment-timezone");
245
+ var zone = "America/Chicago";
246
247
+ // New Orleans time
248
+ var t = moment();
249
+ t.tz(zone);
250
251
+ // Current time
252
+ d = moment();
253
254
+ // If current time is New Orleans time, switch to Los Angeles..
255
+ if (t.hours() === d.hours()) {
256
+ zone = "America/Los_Angeles";
257
258
+ }
259
+ assert.notEqual(d.hours(), t.hours());
260
261
+ // If t = 59s12m then t.setSeconds(60)
262
+ // becones 00s13m so we're fine just doing
263
+ // this and no testRun callback.
264
+ t.add(1, 's');
265
+ // Run a job designed to be executed at a given
266
+ // time in `zone`, making sure that it is a different
267
+ // hour than local time.
268
+ var job = new cron.CronJob(t.seconds() + ' ' + t.minutes() + ' ' + t.hours() + ' * * *', function(){
269
+ assert.ok(true);
270
+ }, null, true, zone);
271
272
+ clock.tick(1000);
273
+ clock.restore();
274
+ job.stop();
275
+ assert.done();
276
+ },
277
'test a job with a date and a given time zone': function (assert) {
278
assert.expect(2);
279