-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correct duration formatting logic (#643)
* fix: correct duration formatting logic * test: add unit test for formatting 3600 seconds as "1h 0m 0s" * test: fix expected output for formatting 3600 seconds as "1h 0m 0s"
- Loading branch information
Showing
2 changed files
with
36 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { seconds_to_duration } from '~/util/time'; | ||
|
||
describe('seconds_to_duration', () => { | ||
test('should format 8145 seconds as "2h 15m 45s"', () => { | ||
expect(seconds_to_duration(8145)).toBe('2h 15m 45s'); | ||
}); | ||
|
||
test('should format 3630 seconds as "1h 0m 30s"', () => { | ||
expect(seconds_to_duration(3630)).toBe('1h 0m 30s'); | ||
}); | ||
|
||
test('should format 3600 seconds as "1h 0m 0s"', () => { | ||
expect(seconds_to_duration(3600)).toBe('1h 0m 0s'); | ||
}); | ||
|
||
test('should format 1830 seconds as "30m 30s"', () => { | ||
expect(seconds_to_duration(1830)).toBe('30m 30s'); | ||
}); | ||
|
||
test('should format 60 seconds as "1m 0s"', () => { | ||
expect(seconds_to_duration(60)).toBe('1m 0s'); | ||
}); | ||
|
||
test('should format 30 seconds as "30s"', () => { | ||
expect(seconds_to_duration(30)).toBe('30s'); | ||
}); | ||
}); |
2b14364
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are screenshots of this commit:
Screenshots using aw-server v0.12.3b18 (click to expand)
Screenshots using aw-server-rust master (click to expand)
Screenshots using aw-server-rust v0.12.3b18 (click to expand)