-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: test case demonstrating .next() issue on composite schedules
- Loading branch information
1 parent
59094ce
commit e7c7924
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
]); | ||
}); | ||
}); | ||
}); |