crontabAsText.spec.tsx 863 B

12345678910111213141516171819202122232425262728
  1. import {shouldUse24Hours} from 'sentry/utils/dates';
  2. import {crontabAsText} from './crontabAsText';
  3. jest.mock('sentry/utils/dates');
  4. describe('crontabAsText', function () {
  5. beforeEach(() => {
  6. jest.mocked(shouldUse24Hours).mockReturnValue(false);
  7. });
  8. it('translates simple crontab', function () {
  9. expect(crontabAsText('* * * * *')).toBe('Every minute');
  10. expect(crontabAsText('10 * * * *')).toBe('At 10 minutes past the hour');
  11. });
  12. it('handles 24 hour clock', function () {
  13. expect(crontabAsText('0 5/* * 1-5 *')).toBe(
  14. 'At 0 minutes past the hour, every * hours, starting at 05:00 AM, January through May'
  15. );
  16. jest.mocked(shouldUse24Hours).mockReturnValue(true);
  17. expect(crontabAsText('0 5/* * 1-5 *')).toBe(
  18. 'At 0 minutes past the hour, every * hours, starting at 05:00, January through May'
  19. );
  20. });
  21. });