time.spec.ts 789 B

12345678910111213141516171819
  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. `('should handle case: $case', ({ input, output }) => {
  15. expect.assertions(1);
  16. expect(formatTime(input)).toBe(output);
  17. });
  18. });