Skip to content

Commit

Permalink
add test for convertUTCtoMs
Browse files Browse the repository at this point in the history
  • Loading branch information
psubram3 committed Oct 7, 2024
1 parent 9270262 commit ca8226d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/utilities/time.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
convertDurationStringToInterval,
convertDurationStringToUs,
convertUsToDurationString,
convertUTCtoMs,
getActivityDirectiveStartTimeMs,
getBalancedDuration,
getDaysInMonth,
Expand Down Expand Up @@ -40,6 +41,20 @@ test('convertDurationStringToUs', () => {
`);
});

test('convertUTCtoMs', () => {
// standard date conversion
expect(convertUTCtoMs('2024-01-01T00:00:00Z')).toEqual(1704067200000);

// DOY doesn't work
expect(convertUTCtoMs('2024-001T00:00:00Z')).toEqual(NaN);

// conversion to DOY is fine if the time zone ("Z") is excluded
expect(convertUTCtoMs(convertDoyToYmd('2024-001T00:00:00') ?? '')).toEqual(1704067200000);

// any other string fails
expect(convertUTCtoMs('not a date')).toEqual(NaN);
});

test('convertDurationStringToInterval', () => {
expect(convertDurationStringToInterval('2y 318d 6h 16m 19s 200ms 0us')).toEqual(
'2 years 318 days 6 hours 16 minutes 19 seconds 200 milliseconds',
Expand Down

0 comments on commit ca8226d

Please sign in to comment.