getPeriod.spec.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import {getPeriod} from 'sentry/utils/getPeriod';
  2. describe('getPeriod()', function () {
  3. const start = new Date('2017-10-03T02:41:20.000Z');
  4. const end = new Date('2017-10-17T14:31:42.000Z');
  5. it('prioritizes period over start/end', function () {
  6. const periodObj = {period: '7d', start, end};
  7. expect(getPeriod(periodObj)).toEqual({
  8. statsPeriod: '7d',
  9. });
  10. });
  11. it('doubles relative period', function () {
  12. const periodObj = {period: '7d'};
  13. expect(getPeriod(periodObj, {shouldDoublePeriod: true})).toEqual({
  14. statsPeriod: '14d',
  15. });
  16. });
  17. it('returns start and end dates', function () {
  18. const periodObj = {start, end};
  19. expect(getPeriod(periodObj)).toEqual({
  20. start: '2017-10-03T02:41:20',
  21. end: '2017-10-17T14:31:42',
  22. });
  23. });
  24. it('doubles period when given start and end dates', function () {
  25. const periodObj = {start, end};
  26. expect(getPeriod(periodObj, {shouldDoublePeriod: true})).toEqual({
  27. start: '2017-09-18T14:50:58',
  28. end: '2017-10-17T14:31:42',
  29. });
  30. });
  31. });