@@ -470,6 +470,56 @@ module('Integration | Component | offering form', function (hooks) {
470
470
assert . ok ( component . duration . minutes . hasError ) ;
471
471
} ) ;
472
472
473
+ test ( 'blanking minutes or hours is ignored' , async function ( assert ) {
474
+ await render ( hbs `<OfferingForm @close={{(noop)}} @save={{(noop)}} />` ) ;
475
+
476
+ // Verify the initial end-date.
477
+ assert . strictEqual (
478
+ this . intl . formatDate ( DateTime . fromObject ( { hour : 9 , minute : 0 } ) . toJSDate ( ) , {
479
+ month : '2-digit' ,
480
+ day : '2-digit' ,
481
+ year : 'numeric' ,
482
+ hour : '2-digit' ,
483
+ minute : '2-digit' ,
484
+ } ) ,
485
+ component . endDate . value ,
486
+ ) ;
487
+
488
+ // Change the duration, verify the calculated end-date.
489
+ await component . duration . minutes . set ( '4' ) ;
490
+ await component . duration . hours . set ( '9' ) ;
491
+ const newEndDate = this . intl . formatDate (
492
+ DateTime . fromObject ( { hour : 17 , minute : 4 } ) . toJSDate ( ) ,
493
+ {
494
+ month : '2-digit' ,
495
+ day : '2-digit' ,
496
+ year : 'numeric' ,
497
+ hour : '2-digit' ,
498
+ minute : '2-digit' ,
499
+ } ,
500
+ ) ;
501
+ assert . strictEqual ( newEndDate , component . endDate . value ) ;
502
+
503
+ // Provide blank input for the duration fields, verify that the end-date does not change again.
504
+ await component . duration . minutes . set ( '' ) ;
505
+ await component . duration . hours . set ( '' ) ;
506
+ assert . strictEqual ( newEndDate , component . endDate . value ) ;
507
+
508
+ // Change the duration again, verify that the calculated end-date has changed and is correct.
509
+ await component . duration . minutes . set ( '12' ) ;
510
+ await component . duration . hours . set ( '2' ) ;
511
+ assert . strictEqual (
512
+ this . intl . formatDate ( DateTime . fromObject ( { hour : 10 , minute : 12 } ) . toJSDate ( ) , {
513
+ month : '2-digit' ,
514
+ day : '2-digit' ,
515
+ year : 'numeric' ,
516
+ hour : '2-digit' ,
517
+ minute : '2-digit' ,
518
+ } ) ,
519
+ component . endDate . value ,
520
+ ) ;
521
+ } ) ;
522
+
473
523
test ( 'learner manager is not present in small-group mode' , async function ( assert ) {
474
524
await render ( hbs `<OfferingForm @close={{(noop)}} @smallGroupMode={{true}} />` ) ;
475
525
assert . notOk ( component . learnerManager . learnerSelectionManager . isPresent ) ;
0 commit comments