-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Shared JS/TS Conversions Part 3 (#3500)
- Loading branch information
1 parent
fe14916
commit f461fa7
Showing
9 changed files
with
44 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { formatTimeFromSeconds, formatTimeToNow } from './dates' | ||
|
||
describe('formatTimeToNow', () => { | ||
it('returns null when date is null', () => { | ||
expect(formatTimeToNow(undefined)).toBe(null) | ||
}) | ||
|
||
it('returns the correct time format when date is a unix timestamp', () => { | ||
vi.useFakeTimers().setSystemTime(new Date('2025-01-01')) | ||
expect(formatTimeToNow(1715731200)).toBe('8 months ago') | ||
vi.useRealTimers() | ||
}) | ||
|
||
it('returns the correct time format when date is a iso string', () => { | ||
vi.useFakeTimers().setSystemTime(new Date('2025-01-01')) | ||
expect(formatTimeToNow('2024-09-01')).toBe('4 months ago') | ||
vi.useRealTimers() | ||
}) | ||
}) | ||
|
||
describe('formatTimeFromSeconds', () => { | ||
it('returns "N/A" when totalSeconds is null', () => { | ||
expect(formatTimeFromSeconds(null)).toBe('N/A') | ||
}) | ||
|
||
it('returns "N/A" when totalSeconds is undefined', () => { | ||
expect(formatTimeFromSeconds(undefined)).toBe('N/A') | ||
}) | ||
|
||
it('returns "0s" when totalSeconds is 0', () => { | ||
expect(formatTimeFromSeconds(0)).toBe('0s') | ||
}) | ||
|
||
it('returns the correct time format when totalSeconds is greater than 0', () => { | ||
expect(formatTimeFromSeconds(3661)).toBe('1h 1m 1s') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
src/shared/utils/snakeifyKeys.js → src/shared/utils/snakeifyKeys.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.