Skip to content

Commit

Permalink
More tests for L
Browse files Browse the repository at this point in the history
  • Loading branch information
Kniggebrot committed Jul 26, 2023
1 parent c6b48cd commit cfc3e8e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,12 @@ describe('validate', () => {
const validDOM = isValidCron('* * L * *', {allowLast: true})
expect(validDOM).toBeTruthy()

const validDOMAlias = isValidCron('* * L * WED', {allowLast: true, alias:true})
expect(validDOMAlias).toBeTruthy()

const validDOMsec = isValidCron('* * * L * THU', {allowLast: true, alias: true, seconds: true})
expect(validDOMsec).toBeTruthy()

const validDOMOffset = isValidCron('* * L-2 * *', {allowLast: true})
expect(validDOMOffset).toBeTruthy()

Expand All @@ -618,4 +624,21 @@ describe('validate', () => {
const validWithSeconds = isValidCron('L * * * * *', {allowLast: true, seconds: true})
expect(validWithSeconds).toBeFalsy()
})

it('should not accept L in invalid places or with invalid offsets/values', () => {
const validDOM = isValidCron('* L L * *', {allowLast: true})
expect(validDOM).toBeFalsy()

const validDOMOffset = isValidCron('* L-2 L-3 * *', {allowLast: true})
expect(validDOMOffset).toBeFalsy()

const validDOW = isValidCron('* * * * L *', {allowLast: true, seconds: true})
expect(validDOW).toBeFalsy()

const validDOWDay = isValidCron('* * * * 2L-2', {allowLast: true})
expect(validDOWDay).toBeFalsy()

const validDOMDay = isValidCron('* * * 3L * 2L', {allowLast: true, seconds: true})
expect(validDOMDay).toBeFalsy()
})
})

0 comments on commit cfc3e8e

Please sign in to comment.