Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix test file for old nodejs version
  • Loading branch information
immanuel192 committed Aug 13, 2018
1 parent 877ecee commit 454c812
Showing 1 changed file with 57 additions and 57 deletions.
114 changes: 57 additions & 57 deletions tests/test-crontime.js
@@ -1,45 +1,45 @@
var chai = require('chai'),
expect = chai.expect,
cron = require('../lib/cron');
cron = require('../lib/cron');

describe('crontime', function() {
it('should test stars (* * * * * *)', function() {
expect(function() {
describe('crontime', function () {
it('should test stars (* * * * * *)', function () {
expect(function () {
new cron.CronTime('* * * * * *');
}).to.not.throw(Error);
});

it('should test digit (0 * * * * *)', function() {
expect(function() {
it('should test digit (0 * * * * *)', function () {
expect(function () {
new cron.CronTime('0 * * * * *');
}).to.not.throw(Error);
});

it('should test multi digits (08 * * * * *)', function() {
expect(function() {
it('should test multi digits (08 * * * * *)', function () {
expect(function () {
new cron.CronTime('08 * * * * *');
}).to.not.throw(Error);
});

it('should test all digits (08 8 8 8 8 5)', function() {
expect(function() {
it('should test all digits (08 8 8 8 8 5)', function () {
expect(function () {
new cron.CronTime('08 * * * * *');
}).to.not.throw(Error);
});

it('should test too many digits (08 8 8 8 8 5)', function() {
expect(function() {
it('should test too many digits (08 8 8 8 8 5)', function () {
expect(function () {
new cron.CronTime('08 * * * * *');
}).to.not.throw(Error);
});

it('should test standard cron format (* * * * *)', function() {
expect(function() {
it('should test standard cron format (* * * * *)', function () {
expect(function () {
new cron.CronTime('* * * * *');
}).to.not.throw(Error);
});

it('should test standard cron format (8 8 8 8 5)', function() {
it('should test standard cron format (8 8 8 8 5)', function () {
var standard = new cron.CronTime('8 8 8 8 5');
var extended = new cron.CronTime('0 8 8 8 8 5');

Expand All @@ -51,100 +51,100 @@ describe('crontime', function() {
expect(standard.second).to.deep.eql(extended.second);
});

it('should test hyphen (0-10 * * * * *)', function() {
expect(function() {
it('should test hyphen (0-10 * * * * *)', function () {
expect(function () {
new cron.CronTime('0-10 * * * * *');
}).to.not.throw(Error);
});

it('should test multi hyphens (0-10 0-10 * * * *)', function() {
expect(function() {
it('should test multi hyphens (0-10 0-10 * * * *)', function () {
expect(function () {
new cron.CronTime('0-10 0-10 * * * *');
}).to.not.throw(Error);
});

it('should test all hyphens (0-10 0-10 0-10 0-10 0-10 0-1)', function() {
expect(function() {
it('should test all hyphens (0-10 0-10 0-10 0-10 0-10 0-1)', function () {
expect(function () {
new cron.CronTime('0-10 0-10 0-10 0-10 0-10 0-1');
}).to.not.throw(Error);
});

it('should test comma (0,10 * * * * *)', function() {
expect(function() {
it('should test comma (0,10 * * * * *)', function () {
expect(function () {
new cron.CronTime('0,10 * * * * *');
}).to.not.throw(Error);
});

it('should test multi commas (0,10 0,10 * * * *)', function() {
expect(function() {
it('should test multi commas (0,10 0,10 * * * *)', function () {
expect(function () {
new cron.CronTime('0,10 0,10 * * * *');
}).to.not.throw(Error);
});

it('should test all commas (0,10 0,10 0,10 0,10 0,10 0,1)', function() {
expect(function() {
it('should test all commas (0,10 0,10 0,10 0,10 0,10 0,1)', function () {
expect(function () {
new cron.CronTime('0,10 0,10 0,10 0,10 0,10 0,1');
}).to.not.throw(Error);
});

it('should test alias (* * * * jan *)', function() {
expect(function() {
it('should test alias (* * * * jan *)', function () {
expect(function () {
new cron.CronTime('* * * * jan *');
}).to.not.throw(Error);
});

it('should test multi aliases (* * * * jan,feb *)', function() {
expect(function() {
it('should test multi aliases (* * * * jan,feb *)', function () {
expect(function () {
new cron.CronTime('* * * * jan,feb *');
}).to.not.throw(Error);
});

it('should test all aliases (* * * * jan,feb mon,tue)', function() {
expect(function() {
it('should test all aliases (* * * * jan,feb mon,tue)', function () {
expect(function () {
new cron.CronTime('* * * * jan,feb mon,tue');
}).to.not.throw(Error);
});

it('should test every second monday (* * * * * mon/2)');

it('should test unknown alias (* * * * jar *)', function() {
expect(function() {
it('should test unknown alias (* * * * jar *)', function () {
expect(function () {
new cron.CronTime('* * * * jar *');
}).to.throw(Error);
});

it('should test unknown alias - short (* * * * j *)', function() {
expect(function() {
it('should test unknown alias - short (* * * * j *)', function () {
expect(function () {
new cron.CronTime('* * * * j *');
}).to.throw(Error);
});

it('should test Date', function() {
it('should test Date', function () {
var d = new Date();
var ct = new cron.CronTime(d);
expect(ct.source.isSame(d.getTime())).to.be.true
});

it('should test day roll-over', function() {
it('should test day roll-over', function () {
var numHours = 24;
var ct = new cron.CronTime('0 0 17 * * *');

for (var hr = 0; hr < numHours; hr++) {
var start = new Date(2012, 3, 16, hr, 30, 30);
var next = ct._getNextDateFrom(start);

expect(next - start).to.be.lt(24*60*60*1000);
expect(next - start).to.be.lt(24 * 60 * 60 * 1000);
expect(next).to.be.gt(start);
}
});

it('should test illegal repetition syntax', function() {
expect(function(){
it('should test illegal repetition syntax', function () {
expect(function () {
new cron.CronTime('* * /4 * * *');
}).to.throw(Error);
});

it('should test next date', function() {
it('should test next date', function () {
var ct = new cron.CronTime('0 0 */4 * * *');

var nextDate = new Date();
Expand All @@ -155,51 +155,51 @@ describe('crontime', function() {
expect(nextdt.hours() % 4).to.eql(0);
});

it('should test next date from invalid date', function() {
it('should test next date from invalid date', function () {
var ct = new cron.CronTime('0 0 * * * *');
var nextDate = new Date('My invalid date string');
var nextdt = ct._getNextDateFrom(nextDate);

expect(nextdt.toString()).to.eql('Invalid date');
});

it('should test next real date', function() {
it('should test next real date', function () {
var ct = new cron.CronTime(new Date());

var nextDate = new Date();
nextDate.setMonth(nextDate.getMonth()+1);
nextDate.setMonth(nextDate.getMonth() + 1);
expect(nextDate).to.be.gt(ct.source);
var nextdt = ct._getNextDateFrom(nextDate);
expect(nextdt.isSame(nextDate)).to.be.true;
});

it('should test next month selection');

describe('should throw an exception because `L` not supported', function() {
describe('should throw an exception because `L` not supported', function () {

it('(* * * L * *)', function() {
expect(function() {
it('(* * * L * *)', function () {
expect(function () {
new cron.CronTime('* * * L * *');
}).to.throw(Error);

});

it('(* * * * * L)', function() {
expect(function() {
it('(* * * * * L)', function () {
expect(function () {
new cron.CronTime('* * * * * L');
}).to.throw(Error);
});
});

it('should strip off millisecond', ()=>{
const cronTime = new cron.CronTime('0 */10 * * * *');
const x = cronTime._getNextDateFrom(new Date("2018-08-10T02:20:00.999Z"));
it('should strip off millisecond', function () {
var cronTime = new cron.CronTime('0 */10 * * * *');
var x = cronTime._getNextDateFrom(new Date("2018-08-10T02:20:00.999Z"));
expect(x.toISOString()).to.equal('2018-08-10T02:30:00.000Z');
});

it('should strip off millisecond (2)', ()=>{
const cronTime = new cron.CronTime('0 */10 * * * *');
const x = cronTime._getNextDateFrom(new Date("2018-08-10T02:19:59.999Z"));
it('should strip off millisecond (2)', function () {
var cronTime = new cron.CronTime('0 */10 * * * *');
var x = cronTime._getNextDateFrom(new Date("2018-08-10T02:19:59.999Z"));
expect(x.toISOString()).to.equal('2018-08-10T02:20:00.000Z');
});
});

0 comments on commit 454c812

Please sign in to comment.