scheduleAsText.spec.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import type {MonitorConfig} from '../types';
  2. import {ScheduleType} from '../types';
  3. import {scheduleAsText} from './scheduleAsText';
  4. describe('scheduleAsText', function () {
  5. it('uses crontabAsText', function () {
  6. const config: MonitorConfig = {
  7. checkin_margin: 0,
  8. max_runtime: 0,
  9. timezone: 'utc',
  10. schedule_type: ScheduleType.CRONTAB,
  11. schedule: '10 * * * *',
  12. };
  13. expect(scheduleAsText(config)).toBe('At 10 minutes past the hour');
  14. });
  15. it('translates interval conigs', function () {
  16. const config: MonitorConfig = {
  17. checkin_margin: 0,
  18. max_runtime: 0,
  19. timezone: 'utc',
  20. schedule_type: ScheduleType.INTERVAL,
  21. schedule: [1, 'minute'],
  22. };
  23. expect(scheduleAsText({...config, schedule: [1, 'minute']})).toBe('Every minute');
  24. expect(scheduleAsText({...config, schedule: [1, 'hour']})).toBe('Every hour');
  25. expect(scheduleAsText({...config, schedule: [1, 'day']})).toBe('Every day');
  26. expect(scheduleAsText({...config, schedule: [1, 'week']})).toBe('Every week');
  27. expect(scheduleAsText({...config, schedule: [1, 'month']})).toBe('Every month');
  28. expect(scheduleAsText({...config, schedule: [1, 'year']})).toBe('Every year');
  29. expect(scheduleAsText({...config, schedule: [5, 'minute']})).toBe('Every 5 minutes');
  30. expect(scheduleAsText({...config, schedule: [5, 'hour']})).toBe('Every 5 hours');
  31. expect(scheduleAsText({...config, schedule: [5, 'day']})).toBe('Every 5 days');
  32. expect(scheduleAsText({...config, schedule: [5, 'week']})).toBe('Every 5 weeks');
  33. expect(scheduleAsText({...config, schedule: [5, 'month']})).toBe('Every 5 months');
  34. expect(scheduleAsText({...config, schedule: [5, 'year']})).toBe('Every 5 years');
  35. });
  36. });