@@ -1042,14 +1042,41 @@ describe('datepicker directive', function () {
1042
1042
expect ( dropdownEl . find ( 'li' ) . length ) . toBe ( 2 ) ;
1043
1043
} ) ;
1044
1044
1045
- it ( 'should have four buttons' , function ( ) {
1045
+ it ( 'should have three buttons' , function ( ) {
1046
1046
expect ( buttons . length ) . toBe ( 3 ) ;
1047
1047
1048
1048
expect ( buttons . eq ( 0 ) . text ( ) ) . toBe ( 'Today' ) ;
1049
1049
expect ( buttons . eq ( 1 ) . text ( ) ) . toBe ( 'Clear' ) ;
1050
1050
expect ( buttons . eq ( 2 ) . text ( ) ) . toBe ( 'Done' ) ;
1051
1051
} ) ;
1052
1052
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
+
1053
1080
it ( 'should have a button to clear value' , function ( ) {
1054
1081
buttons . eq ( 1 ) . click ( ) ;
1055
1082
expect ( $rootScope . date ) . toBe ( null ) ;
0 commit comments