useMetricsIntervalParam.spec.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import {getIntervalOptionsForStatsPeriod} from 'sentry/views/metrics/utils/useMetricsIntervalParam';
  2. describe('getIntervalOptionsForStatsPeriod', () => {
  3. it('returns options for mixed metrics', () => {
  4. expect(
  5. getIntervalOptionsForStatsPeriod(
  6. {period: '1h', start: null, end: null, utc: null},
  7. false
  8. )
  9. ).toEqual([
  10. {value: '1m', label: '1 minute'},
  11. {value: '5m', label: '5 minutes'},
  12. {value: '15m', label: '15 minutes'},
  13. ]);
  14. expect(
  15. getIntervalOptionsForStatsPeriod(
  16. {period: '90d', start: null, end: null, utc: null},
  17. false
  18. )
  19. ).toEqual([
  20. {value: '1d', label: '1 day'},
  21. {value: '1w', label: '1 week'},
  22. {value: '4w', label: '1 month'},
  23. ]);
  24. });
  25. it('returns options for custom metrics', () => {
  26. expect(
  27. getIntervalOptionsForStatsPeriod(
  28. {period: '1h', start: null, end: null, utc: null},
  29. true
  30. )
  31. ).toEqual([
  32. {value: '10s', label: '10 seconds'},
  33. {value: '1m', label: '1 minute'},
  34. {value: '5m', label: '5 minutes'},
  35. {value: '15m', label: '15 minutes'},
  36. ]);
  37. expect(
  38. getIntervalOptionsForStatsPeriod(
  39. {period: '90d', start: null, end: null, utc: null},
  40. true
  41. )
  42. ).toEqual([
  43. {value: '1d', label: '1 day'},
  44. {value: '1w', label: '1 week'},
  45. {value: '4w', label: '1 month'},
  46. ]);
  47. });
  48. });