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