X-Git-Url: https://git.r.bdr.sh/rbdr/forum/blobdiff_plain/a7cf03c192470cbab13edeb1aec99e0c66dede10..be1ce532b26aea4e3e2258da78849bd245f7f78b:/src/lib/utils/readable_time.test.ts diff --git a/src/lib/utils/readable_time.test.ts b/src/lib/utils/readable_time.test.ts index 5d8ba27..6c4b4d4 100644 --- a/src/lib/utils/readable_time.test.ts +++ b/src/lib/utils/readable_time.test.ts @@ -1,83 +1,71 @@ import { readableTime } from './readable_time'; describe('readableTime', () => { + test('it shows negative time as 0', () => { + const response = readableTime(-1000); - test('it shows negative time as 0', () => { + expect(response.count).toBe(0); + expect(response.label).toContain('seconds'); + }); - const response = readableTime(-1000); + test('uses seconds as the smallest unit', () => { + const response = readableTime(10); - expect(response.count).toBe(0); - expect(response.label).toContain('seconds'); - }); + expect(response.count).toBe(0); + expect(response.label).toContain('seconds'); + }); - test('uses seconds as the smallest unit', () => { + test('correctly divides miliseconds into seconds', () => { + const response = readableTime(4000); - const response = readableTime(10); + expect(response.count).toBe(4); + }); - expect(response.count).toBe(0); - expect(response.label).toContain('seconds'); - }); + test('uses seconds if the time is < 1 minute', () => { + const response = readableTime(59 * 1000); - test('correctly divides miliseconds into seconds', () => { + expect(response.label).toContain('seconds'); + }); - const response = readableTime(4000); + test('correctly divides miliseconds into minutes', () => { + const response = readableTime(2 * 60 * 1000); - expect(response.count).toBe(4); - }); + expect(response.count).toBe(2); + }); - test('uses seconds if the time is < 1 minute', () => { + test('uses minutes if the time is < 1 hour', () => { + const response = readableTime(59 * 60 * 1000); - const response = readableTime(59 * 1000); + expect(response.label).toContain('minutes'); + }); - expect(response.label).toContain('seconds'); - }); + test('correctly divides miliseconds into hours', () => { + const response = readableTime(2 * 60 * 60 * 1000); - test('correctly divides miliseconds into minutes', () => { + expect(response.count).toBe(2); + }); - const response = readableTime(2 * 60 * 1000); + test('uses hours if the time is < 1 days', () => { + const response = readableTime(23 * 60 * 60 * 1000); - expect(response.count).toBe(2); - }); + expect(response.label).toContain('hours'); + }); - test('uses minutes if the time is < 1 hour', () => { + test('correctly divides miliseconds into days', () => { + const response = readableTime(2 * 24 * 60 * 60 * 1000); - const response = readableTime(59 * 60 * 1000); + expect(response.count).toBe(2); + }); - expect(response.label).toContain('minutes'); - }); + test('uses days if the time is >= 1 day', () => { + const response = readableTime(364 * 24 * 60 * 60 * 1000); - test('correctly divides miliseconds into hours', () => { + expect(response.label).toContain('days'); + }); - const response = readableTime(2 * 60 * 60 * 1000); + test('uses days as the maximum unit', () => { + const response = readableTime(Number.MAX_VALUE); - expect(response.count).toBe(2); - }); - - test('uses hours if the time is < 1 days', () => { - - const response = readableTime(23 * 60 * 60 * 1000); - - expect(response.label).toContain('hours'); - }); - - test('correctly divides miliseconds into days', () => { - - const response = readableTime(2 * 24 * 60 * 60 * 1000); - - expect(response.count).toBe(2); - }); - - test('uses days if the time is >= 1 day', () => { - - const response = readableTime(364 * 24 * 60 * 60 * 1000); - - expect(response.label).toContain('days'); - }); - - test('uses days as the maximum unit', () => { - - const response = readableTime(Number.MAX_VALUE); - - expect(response.label).toContain('days'); - }); + expect(response.label).toContain('days'); + }); });