File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -450,17 +450,30 @@ describe('getJsDate', () => {
450450} ) ;
451451
452452describe ( 'trimDateTimeStringOverflow' , ( ) => {
453- it . each ( [
453+ const dateTimeTexts = [
454454 '2024' ,
455455 '2012-04' ,
456456 '2012-04-20' ,
457457 '2012-04-20T12' ,
458458 '2012-04-20T12:13' ,
459459 '2012-04-20T12:13:14' ,
460460 '2012-04-20T12:13:14.321' ,
461- ] ) ( 'should trim date time string overflow: %s' , expected => {
462- const given = `${ expected } overflow` ;
463- const actual = DateUtils . trimDateTimeStringOverflow ( given ) ;
464- expect ( actual ) . toEqual ( expected ) ;
465- } ) ;
461+ ] ;
462+
463+ it . each ( dateTimeTexts ) (
464+ 'should return given string if no overflow: %s' ,
465+ given => {
466+ const actual = DateUtils . trimDateTimeStringOverflow ( given ) ;
467+ expect ( actual ) . toEqual ( given ) ;
468+ }
469+ ) ;
470+
471+ it . each ( dateTimeTexts ) (
472+ 'should trim date time string overflow: %s' ,
473+ expected => {
474+ const given = `${ expected } overflow` ;
475+ const actual = DateUtils . trimDateTimeStringOverflow ( given ) ;
476+ expect ( actual ) . toEqual ( expected ) ;
477+ }
478+ ) ;
466479} ) ;
Original file line number Diff line number Diff line change @@ -394,6 +394,10 @@ export class DateUtils {
394394 true
395395 ) ;
396396
397+ if ( overflow === '' ) {
398+ return dateTimeString ;
399+ }
400+
397401 return dateTimeString . slice ( 0 , - overflow . length ) ;
398402 }
399403}
You can’t perform that action at this time.
0 commit comments