@@ -193,10 +193,15 @@ describe("parseDuration", () => {
193193 } ) ;
194194
195195 test ( "parses case-insensitive long format" , ( ) => {
196+ // @ts -expect-error - mixed-case (not in type but accepted at runtime)
196197 expect ( parseDuration ( "53 YeArS" ) ) . toBe ( 1_672_552_800_000 ) ;
198+ // @ts -expect-error - mixed-case (not in type but accepted at runtime)
197199 expect ( parseDuration ( "53 WeEkS" ) ) . toBe ( 32_054_400_000 ) ;
200+ // @ts -expect-error - mixed-case (not in type but accepted at runtime)
198201 expect ( parseDuration ( "53 DaYS" ) ) . toBe ( 4_579_200_000 ) ;
202+ // @ts -expect-error - mixed-case (not in type but accepted at runtime)
199203 expect ( parseDuration ( "53 HoUrs" ) ) . toBe ( 190_800_000 ) ;
204+ // @ts -expect-error - mixed-case (not in type but accepted at runtime)
200205 expect ( parseDuration ( "53 MiLliSeCondS" ) ) . toBe ( 53 ) ;
201206 } ) ;
202207 } ) ;
@@ -237,43 +242,55 @@ describe("parseDuration", () => {
237242
238243 describe ( "error cases" , ( ) => {
239244 test ( "throws on invalid format" , ( ) => {
245+ // @ts -expect-error - invalid format
240246 expect ( ( ) => parseDuration ( "invalid" ) ) . toThrow (
241247 'Invalid duration format: "invalid"' ,
242248 ) ;
249+ // @ts -expect-error - invalid format
243250 expect ( ( ) => parseDuration ( "10-.5" ) ) . toThrow (
244251 'Invalid duration format: "10-.5"' ,
245252 ) ;
253+ // @ts -expect-error - invalid format
246254 expect ( ( ) => parseDuration ( "foo" ) ) . toThrow (
247255 'Invalid duration format: "foo"' ,
248256 ) ;
249257 } ) ;
250258
251259 test ( "throws on empty string" , ( ) => {
260+ // @ts -expect-error - empty string
252261 expect ( ( ) => parseDuration ( "" ) ) . toThrow ( 'Invalid duration format: ""' ) ;
253262 } ) ;
254263
255264 test ( "throws on missing number" , ( ) => {
265+ // @ts -expect-error - unit without number
256266 expect ( ( ) => parseDuration ( "ms" ) ) . toThrow (
257267 'Invalid duration format: "ms"' ,
258268 ) ;
269+ // @ts -expect-error - unit without number
259270 expect ( ( ) => parseDuration ( "s" ) ) . toThrow ( 'Invalid duration format: "s"' ) ;
271+ // @ts -expect-error - unit without number
260272 expect ( ( ) => parseDuration ( "m" ) ) . toThrow ( 'Invalid duration format: "m"' ) ;
273+ // @ts -expect-error - unit without number
261274 expect ( ( ) => parseDuration ( "h" ) ) . toThrow ( 'Invalid duration format: "h"' ) ;
262275 } ) ;
263276
264277 test ( "throws on unknown unit" , ( ) => {
278+ // @ts -expect-error - unknown unit
265279 expect ( ( ) => parseDuration ( "100x" ) ) . toThrow (
266280 'Invalid duration format: "100x"' ,
267281 ) ;
282+ // @ts -expect-error - unknown unit
268283 expect ( ( ) => parseDuration ( "5z" ) ) . toThrow (
269284 'Invalid duration format: "5z"' ,
270285 ) ;
271286 } ) ;
272287
273288 test ( "throws on multiple units" , ( ) => {
289+ // @ts -expect-error - multiple units
274290 expect ( ( ) => parseDuration ( "1h30m" ) ) . toThrow (
275291 'Invalid duration format: "1h30m"' ,
276292 ) ;
293+ // @ts -expect-error - multiple units
277294 expect ( ( ) => parseDuration ( "5s100ms" ) ) . toThrow (
278295 'Invalid duration format: "5s100ms"' ,
279296 ) ;
@@ -283,34 +300,44 @@ describe("parseDuration", () => {
283300 expect ( ( ) => parseDuration ( " 5s" ) ) . toThrow (
284301 'Invalid duration format: " 5s"' ,
285302 ) ;
303+ // @ts -expect-error - trailing space
286304 expect ( ( ) => parseDuration ( "5s " ) ) . toThrow (
287305 'Invalid duration format: "5s "' ,
288306 ) ;
289307 } ) ;
290308
291309 test ( "throws on special characters" , ( ) => {
310+ // @ts -expect-error - special characters
292311 expect ( ( ) => parseDuration ( "5s!" ) ) . toThrow (
293312 'Invalid duration format: "5s!"' ,
294313 ) ;
314+ // @ts -expect-error - special characters
295315 expect ( ( ) => parseDuration ( "@5s" ) ) . toThrow (
296316 'Invalid duration format: "@5s"' ,
297317 ) ;
298318 } ) ;
299319
300320 test ( "throws on non-string types" , ( ) => {
321+ // @ts -expect-error - non-string type
301322 expect ( ( ) => parseDuration ( undefined as unknown as string ) ) . toThrow (
302323 TypeError ,
303324 ) ;
325+ // @ts -expect-error - non-string type
304326 expect ( ( ) => parseDuration ( null as unknown as string ) ) . toThrow ( TypeError ) ;
327+ // @ts -expect-error - non-string type
305328 expect ( ( ) => parseDuration ( [ ] as unknown as string ) ) . toThrow ( TypeError ) ;
329+ // @ts -expect-error - non-string type
306330 expect ( ( ) => parseDuration ( { } as unknown as string ) ) . toThrow ( TypeError ) ;
331+ // @ts -expect-error - non-string type
307332 expect ( ( ) => parseDuration ( Number . NaN as unknown as string ) ) . toThrow (
308333 TypeError ,
309334 ) ;
310335 expect ( ( ) =>
336+ // @ts -expect-error - non-string type
311337 parseDuration ( Number . POSITIVE_INFINITY as unknown as string ) ,
312338 ) . toThrow ( TypeError ) ;
313339 expect ( ( ) =>
340+ // @ts -expect-error - non-string type
314341 parseDuration ( Number . NEGATIVE_INFINITY as unknown as string ) ,
315342 ) . toThrow ( TypeError ) ;
316343 } ) ;
0 commit comments