@@ -714,11 +714,39 @@ describe('timepicker directive', function () {
714
714
expect ( getModelState ( ) ) . toEqual ( [ 14 , 40 ] ) ;
715
715
} ) ;
716
716
717
+ it ( 'always pads hours & minutes' , function ( ) {
718
+ // Make sure hours and minutes are padded in 12 hour format
719
+ $rootScope . meridian = true ;
720
+ element = $compile ( '<timepicker ng-model="time" show-meridian="meridian"></timepicker>' ) ( $rootScope ) ;
721
+ $rootScope . $digest ( ) ;
722
+
723
+ var hours = getHoursInputEl ( ) ;
724
+ var minutes = getMinutesInputEl ( ) ;
725
+
726
+ // Make sure the time is padded when the template is first loaded
727
+ expect ( getTimeState ( ) ) . toEqual ( [ '02' , '40' , 'PM' ] ) ;
728
+ expect ( getModelState ( ) ) . toEqual ( [ 14 , 40 ] ) ;
729
+
730
+ changeInputValueTo ( hours , 5 ) ;
731
+ changeInputValueTo ( minutes , 7 ) ;
732
+ $rootScope . $digest ( ) ;
733
+ expect ( getTimeState ( ) ) . toEqual ( [ '05' , '07' , 'PM' ] ) ;
734
+ expect ( getModelState ( ) ) . toEqual ( [ 17 , 7 ] ) ;
735
+
736
+ // Make sure hours and minutes are padded in 24 hour format
737
+ $rootScope . meridian = false ;
738
+ changeInputValueTo ( hours , 0 ) ;
739
+ changeInputValueTo ( minutes , 0 ) ;
740
+ $rootScope . $digest ( ) ;
741
+ expect ( getTimeState ( ) ) . toEqual ( [ '00' , '00' , 'AM' ] ) ;
742
+ expect ( getModelState ( ) ) . toEqual ( [ 0 , 0 ] ) ;
743
+ } ) ;
744
+
717
745
it ( 'updates hours & pads on input change & pads on blur' , function ( ) {
718
746
var el = getHoursInputEl ( ) ;
719
747
720
748
changeInputValueTo ( el , 5 ) ;
721
- expect ( getTimeState ( ) ) . toEqual ( [ '5 ' , '40' , 'PM' ] ) ;
749
+ expect ( getTimeState ( ) ) . toEqual ( [ '05 ' , '40' , 'PM' ] ) ;
722
750
expect ( getModelState ( ) ) . toEqual ( [ 17 , 40 ] ) ;
723
751
724
752
el . blur ( ) ;
@@ -730,7 +758,7 @@ describe('timepicker directive', function () {
730
758
var el = getMinutesInputEl ( ) ;
731
759
732
760
changeInputValueTo ( el , 9 ) ;
733
- expect ( getTimeState ( ) ) . toEqual ( [ '02' , '9 ' , 'PM' ] ) ;
761
+ expect ( getTimeState ( ) ) . toEqual ( [ '02' , '09 ' , 'PM' ] ) ;
734
762
expect ( getModelState ( ) ) . toEqual ( [ 14 , 9 ] ) ;
735
763
736
764
el . blur ( ) ;
0 commit comments