1- import { badWords , formatANoun , parseDuration } from "./util" ;
1+ import { badWords , formatANoun , formatTime , parseDuration } from "./util" ;
22
33describe ( "bad words filter" , ( ) => {
44 it ( "sort of works" , ( ) => {
@@ -18,7 +18,7 @@ describe("bad words filter", () => {
1818 } ) ;
1919} ) ;
2020
21- it ( "parseDuration works" , ( ) => {
21+ it ( "formatANoun works" , ( ) => {
2222 expect ( formatANoun ( "Set" ) ) . toBe ( "a Set" ) ;
2323 expect ( formatANoun ( "UltraSet" ) ) . toBe ( "an UltraSet" ) ;
2424 expect ( formatANoun ( "GhostSet" ) ) . toBe ( "a GhostSet" ) ;
@@ -37,3 +37,23 @@ it("parseDuration works", () => {
3737 expect ( parseDuration ( "300" ) ) . toBe ( null ) ;
3838 expect ( parseDuration ( "" ) ) . toBe ( null ) ;
3939} ) ;
40+
41+ it ( "formatTime works" , ( ) => {
42+ const check = ( ms , expected ) => {
43+ expect ( formatTime ( ms ) ) . toBe ( expected ) ;
44+ expect ( formatTime ( ms , true ) ) . toBe ( expected . slice ( 0 , - 3 ) ) ;
45+ } ;
46+ check ( - 12345 , "00:00.00" ) ;
47+ check ( 0 , "00:00.00" ) ;
48+ check ( 999 , "00:00.99" ) ;
49+ check ( 12349 , "00:12.34" ) ;
50+ check ( 59999 , "00:59.99" ) ;
51+ check ( 123000 , "02:03.00" ) ;
52+ check ( 123459 , "02:03.45" ) ;
53+ check ( 1234599 , "20:34.59" ) ;
54+ check ( 3599999 , "59:59.99" ) ;
55+ check ( 3600000 , "01:00:00.00" ) ;
56+ check ( 3725669 , "01:02:05.66" ) ;
57+ check ( 37256699 , "10:20:56.69" ) ;
58+ check ( 372566999 , "4:07:29:26.99" ) ;
59+ } ) ;
0 commit comments