utils.spec.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import {getStartFromTimeWindow} from 'sentry/views/monitors/components/overviewTimeline/utils';
  2. describe('Crons Timeline Utils', function () {
  3. const end = new Date('2023-06-15T12:00:00Z');
  4. describe('getStartFromTimeWindow', function () {
  5. it('correctly computes for 1h', function () {
  6. const expectedStart = new Date('2023-06-15T11:00:00Z');
  7. const start = getStartFromTimeWindow(end, '1h');
  8. expect(start).toEqual(expectedStart);
  9. });
  10. it('correctly computes for 24h', function () {
  11. const expectedStart = new Date('2023-06-14T12:00:00Z');
  12. const start = getStartFromTimeWindow(end, '24h');
  13. expect(start).toEqual(expectedStart);
  14. });
  15. it('correctly computes for 7d', function () {
  16. const expectedStart = new Date('2023-06-08T12:00:00Z');
  17. const start = getStartFromTimeWindow(end, '7d');
  18. expect(start).toEqual(expectedStart);
  19. });
  20. it('correctly computes for 30d', function () {
  21. const expectedStart = new Date('2023-05-16T12:00:00Z');
  22. const start = getStartFromTimeWindow(end, '30d');
  23. expect(start).toEqual(expectedStart);
  24. });
  25. });
  26. });