time.spec.ts 845 B

1234567891011121314151617181920
  1. import { formatTime } from './time';
  2. describe(formatTime.name, () => {
  3. it.each`
  4. case | input | output
  5. ${'zero'} | ${0} | ${'00:00'}
  6. ${null} | ${null} | ${''}
  7. ${'less than ten seconds'} | ${7} | ${'00:07'}
  8. ${'less than one minute'} | ${26} | ${'00:26'}
  9. ${'less than 10 minutes'} | ${593} | ${'09:53'}
  10. ${'less than one hour'} | ${3176} | ${'52:56'}
  11. ${'more than one hour'} | ${3615} | ${'1:00:15'}
  12. ${'more than one day'} | ${86465} | ${'1 day, 01:05'}
  13. ${'negative values'} | ${-86465} | ${'-1 day, 01:05'}
  14. ${'floating point values'} | ${119.99} | ${'02:00'}
  15. `('should handle case: $case', ({ input, output }) => {
  16. expect.assertions(1);
  17. expect(formatTime(input)).toBe(output);
  18. });
  19. });