@@ -1042,14 +1042,41 @@ describe('datepicker directive', function () {
10421042 expect ( dropdownEl . find ( 'li' ) . length ) . toBe ( 2 ) ;
10431043 } ) ;
10441044
1045- it ( 'should have four buttons' , function ( ) {
1045+ it ( 'should have three buttons' , function ( ) {
10461046 expect ( buttons . length ) . toBe ( 3 ) ;
10471047
10481048 expect ( buttons . eq ( 0 ) . text ( ) ) . toBe ( 'Today' ) ;
10491049 expect ( buttons . eq ( 1 ) . text ( ) ) . toBe ( 'Clear' ) ;
10501050 expect ( buttons . eq ( 2 ) . text ( ) ) . toBe ( 'Done' ) ;
10511051 } ) ;
10521052
1053+ it ( 'should have a button to set today date without altering time part' , function ( ) {
1054+ var today = new Date ( ) ;
1055+ buttons . eq ( 0 ) . click ( ) ;
1056+ expect ( $rootScope . date . getFullYear ( ) ) . toBe ( today . getFullYear ( ) ) ;
1057+ expect ( $rootScope . date . getMonth ( ) ) . toBe ( today . getMonth ( ) ) ;
1058+ expect ( $rootScope . date . getDate ( ) ) . toBe ( today . getDate ( ) ) ;
1059+
1060+ expect ( $rootScope . date . getHours ( ) ) . toBe ( 15 ) ;
1061+ expect ( $rootScope . date . getMinutes ( ) ) . toBe ( 30 ) ;
1062+ expect ( $rootScope . date . getSeconds ( ) ) . toBe ( 0 ) ;
1063+ } ) ;
1064+
1065+ it ( 'should have a button to set today date if blank' , function ( ) {
1066+ $rootScope . date = null ;
1067+ $rootScope . $digest ( ) ;
1068+
1069+ var today = new Date ( ) ;
1070+ buttons . eq ( 0 ) . click ( ) ;
1071+ expect ( $rootScope . date . getFullYear ( ) ) . toBe ( today . getFullYear ( ) ) ;
1072+ expect ( $rootScope . date . getMonth ( ) ) . toBe ( today . getMonth ( ) ) ;
1073+ expect ( $rootScope . date . getDate ( ) ) . toBe ( today . getDate ( ) ) ;
1074+
1075+ expect ( $rootScope . date . getHours ( ) ) . toBe ( 0 ) ;
1076+ expect ( $rootScope . date . getMinutes ( ) ) . toBe ( 0 ) ;
1077+ expect ( $rootScope . date . getSeconds ( ) ) . toBe ( 0 ) ;
1078+ } ) ;
1079+
10531080 it ( 'should have a button to clear value' , function ( ) {
10541081 buttons . eq ( 1 ) . click ( ) ;
10551082 expect ( $rootScope . date ) . toBe ( null ) ;
0 commit comments