QueryPerformance.utils.test.ts 770 B

12345678910111213141516171819202122232425
  1. import { describe, expect, it } from 'vitest'
  2. import { formatDuration } from './QueryPerformance.utils'
  3. describe('formatDuration', () => {
  4. it('should format seconds', () => {
  5. expect(formatDuration(1000)).toBe('1.00s')
  6. expect(formatDuration(30000)).toBe('30.00s')
  7. })
  8. it('should format minutes and seconds', () => {
  9. expect(formatDuration(60000)).toBe('1m')
  10. expect(formatDuration(125000)).toBe('2m 5s')
  11. })
  12. it('should format hours, minutes and seconds', () => {
  13. expect(formatDuration(3600000)).toBe('1h')
  14. expect(formatDuration(3661000)).toBe('1h 1m 1s')
  15. })
  16. it('should format days, hours, minutes and seconds', () => {
  17. expect(formatDuration(86400000)).toBe('1d')
  18. expect(formatDuration(90061000)).toBe('1d 1h 1m 1s')
  19. })
  20. })