@@ -353,25 +353,32 @@ describe('relativeTimeToDate', () => {
353353
354354 describe ( 'In the future' , ( ) => {
355355 it ( 'should parse valid natural time' , ( ) => {
356- const text = 'in 12 days 10 hours 24 minutes' ;
356+ const text = 'in 12 days 10 hours 24 minutes 30 seconds ' ;
357357 const { result, status, info } = transform . relativeTimeToDate ( text , now ) ;
358- expect ( result . toISOString ( ) ) . toBe ( '2017-10-08T23:52:16 .617Z' ) ;
358+ expect ( result . toISOString ( ) ) . toBe ( '2017-10-08T23:52:46 .617Z' ) ;
359359 expect ( status ) . toBe ( 'success' ) ;
360360 expect ( info ) . toBe ( 'future' ) ;
361361 } ) ;
362362 } ) ;
363363
364364 describe ( 'In the past' , ( ) => {
365365 it ( 'should parse valid natural time' , ( ) => {
366- const text = '2 days 12 hours 1 minute ago' ;
366+ const text = '2 days 12 hours 1 minute 12 seconds ago' ;
367367 const { result, status, info } = transform . relativeTimeToDate ( text , now ) ;
368- expect ( result . toISOString ( ) ) . toBe ( '2017-09-24T01:27:16 .617Z' ) ;
368+ expect ( result . toISOString ( ) ) . toBe ( '2017-09-24T01:27:04 .617Z' ) ;
369369 expect ( status ) . toBe ( 'success' ) ;
370370 expect ( info ) . toBe ( 'past' ) ;
371371 } ) ;
372372 } ) ;
373373
374374 describe ( 'Error cases' , ( ) => {
375+ it ( 'should error if string is completely gibberish' , ( ) => {
376+ expect ( transform . relativeTimeToDate ( 'gibberishasdnklasdnjklasndkl123j123' ) ) . toEqual ( {
377+ status : 'error' ,
378+ info : "Time should either start with 'in' or end with 'ago'" ,
379+ } ) ;
380+ } ) ;
381+
375382 it ( 'should error if string contains neither `ago` nor `in`' , ( ) => {
376383 expect ( transform . relativeTimeToDate ( '12 hours 1 minute' ) ) . toEqual ( {
377384 status : 'error' ,
0 commit comments