responseRateChart.spec.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import type {Series} from 'sentry/types/echarts';
  2. import {getAxisMaxForPercentageSeries} from 'sentry/views/performance/http/responseRateChart';
  3. describe('ResponseRateChart', function () {
  4. describe('getAxisMaxForPercentageSeries', function () {
  5. it('Returns nearest significant digit for small series', function () {
  6. expect(getAxisMaxForPercentageSeries([HTTP_5XX_SERIES])).toBeCloseTo(0.0001);
  7. });
  8. it('Returns 1 for larger series', function () {
  9. expect(getAxisMaxForPercentageSeries([HTTP_2XX_SERIES])).toBeCloseTo(1);
  10. });
  11. it('Takes all series into account', function () {
  12. expect(
  13. getAxisMaxForPercentageSeries([HTTP_2XX_SERIES, HTTP_5XX_SERIES])
  14. ).toBeCloseTo(1);
  15. });
  16. });
  17. });
  18. const HTTP_2XX_SERIES: Series = {
  19. seriesName: '5XX',
  20. data: [
  21. {
  22. value: 0.9812,
  23. name: '2024-03-12T13:30:00-04:00',
  24. },
  25. {
  26. value: 0.9992,
  27. name: '2024-03-12T14:00:00-04:00',
  28. },
  29. ],
  30. };
  31. const HTTP_5XX_SERIES: Series = {
  32. seriesName: '5XX',
  33. data: [
  34. {
  35. value: 0.00006713689346852019,
  36. name: '2024-03-12T13:30:00-04:00',
  37. },
  38. {
  39. value: 0.000041208717375685543,
  40. name: '2024-03-12T14:00:00-04:00',
  41. },
  42. ],
  43. };