unit.spec.ts 727 B

123456789101112131415161718192021222324
  1. import {makeTimelineFormatter} from 'sentry/utils/profiling/units/units';
  2. describe('makeTimelineFormatter', () => {
  3. it('handles base', () => {
  4. const formatter = makeTimelineFormatter('seconds');
  5. expect(formatter(61)).toBe('01:01.000');
  6. });
  7. it('formats s', () => {
  8. const formatter = makeTimelineFormatter('seconds');
  9. expect(formatter(1)).toBe('00:01.000');
  10. expect(formatter(12)).toBe('00:12.000');
  11. });
  12. it('formats ms', () => {
  13. const formatter = makeTimelineFormatter('seconds');
  14. expect(formatter(1.543)).toBe('00:01.543');
  15. });
  16. it('doesnt overflow template', () => {
  17. const formatter = makeTimelineFormatter('seconds');
  18. expect(formatter(1.54355)).toBe('00:01.543');
  19. });
  20. });