fix(cron): selecting the first sunday of the month

This commit is contained in:
Julien Fontanet 2018-04-03 17:19:15 +02:00
parent bc86984f19
commit 7e627c953e
3 changed files with 10 additions and 6 deletions

View File

@ -41,4 +41,8 @@ describe('next()', () => {
'no solutions found for this schedule'
)
})
it('select the first sunday of the month', () => {
expect(N('* * * * 0', '2018-03-31T00:00')).toBe('2018-04-01T00:00')
})
})

View File

@ -176,10 +176,10 @@ export default createParser({
range: [0, 11],
},
{
aliases: 'mon tue wen thu fri sat sun'.split(' '),
aliases: 'sun mon tue wen thu fri sat'.split(' '),
name: 'dayOfWeek',
post: value => (value === 0 ? 7 : value),
range: [1, 7],
post: value => (value === 7 ? 0 : value),
range: [0, 6],
},
],
presets: {

View File

@ -23,7 +23,7 @@ describe('parse()', () => {
it('correctly parse days', () => {
expect(parse('* * * * mon,sun')).toEqual({
dayOfWeek: [1, 7],
dayOfWeek: [0, 1],
})
})
@ -40,10 +40,10 @@ describe('parse()', () => {
it('dayOfWeek: 0 and 7 bind to sunday', () => {
expect(parse('* * * * 0')).toEqual({
dayOfWeek: [7],
dayOfWeek: [0],
})
expect(parse('* * * * 7')).toEqual({
dayOfWeek: [7],
dayOfWeek: [0],
})
})
})