Skip to content

Commit

Permalink
Merge pull request #23 from shaunhurley/shaunhurley/schedule-order-issue
Browse files Browse the repository at this point in the history
test: test case demonstrating .next() issue on composite schedules
  • Loading branch information
titanism authored Nov 28, 2023
2 parents 0deb346 + e7c7924 commit 57b6382
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/issues/occurences-next-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const later = require('../..');
const { schedule } = later;
const should = require('should');

describe('Schedule', function () {
later.date.UTC();

describe('next', function () {
const d = new Date('2021-01-01T00:00:00Z');
const e = new Date('2016-01-01T00:00:00Z');

it('should return next three (3) valid dates from a composite schedule', function () {
const s = {
schedules: [
{ s: [0], m: [30], h: [18], D: [1], M: [2] },
{ s: [0], m: [30], h: [17], D: [2], M: [2], Y: [2023] }
],
exceptions: []
};
schedule(s)
.next(3)
.should.eql([
new Date('2023-02-01T18:30:00Z'),
new Date('2023-02-02T17:30:00Z'),
new Date('2024-02-01T18:30:00Z')
]);
});

it('should return next three (3) valid dates from a composite schedule', function () {
const s = {
schedules: [
{ s: [0], m: [30], h: [17], D: [2], M: [2], Y: [2021] },
{ s: [0], m: [30], h: [18], D: [1], M: [1] }
],
exceptions: []
};
schedule(s)
.next(3)
.should.eql([
new Date('2023-02-01T18:30:00Z'),
new Date('2023-02-02T17:30:00Z'),
new Date('2024-02-01T18:30:00Z')
]);
});
});
});

0 comments on commit 57b6382

Please sign in to comment.