-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(synthetics): add static cron method to schedule class (#17250)
closes #16402 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
4 changed files
with
124 additions
and
3 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
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
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
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,26 @@ | ||
import * as synthetics from '../lib'; | ||
|
||
describe('cron', () => { | ||
test('day and weekDay are mutex: given week day', () => { | ||
expect(synthetics.Schedule.cron({ | ||
weekDay: 'MON-FRI', | ||
}).expressionString).toEqual('cron(* * ? * MON-FRI *)'); | ||
}); | ||
|
||
test('day and weekDay are mutex: given month day', () => { | ||
expect(synthetics.Schedule.cron({ | ||
day: '1', | ||
}).expressionString).toEqual('cron(* * 1 * ? *)'); | ||
}); | ||
|
||
test('day and weekDay are mutex: given neither', () => { | ||
expect(synthetics.Schedule.cron({}).expressionString).toEqual('cron(* * * * ? *)'); | ||
}); | ||
|
||
test('day and weekDay are mutex: throw if given both', () => { | ||
expect(() => synthetics.Schedule.cron({ | ||
day: '1', | ||
weekDay: 'MON', | ||
})).toThrow('Cannot supply both \'day\' and \'weekDay\', use at most one'); | ||
}); | ||
}); |