@@ -1091,6 +1091,51 @@ describe('datepicker directive', function () {
10911091 } ) ;
10921092 } ) ;
10931093
1094+ describe ( 'dynamic custom format' , function ( ) {
1095+ beforeEach ( inject ( function ( ) {
1096+ $rootScope . format = 'dd-MMMM-yyyy' ;
1097+ var wrapElement = $compile ( '<div><input ng-model="date" datepicker-popup="{{format}}"><div>' ) ( $rootScope ) ;
1098+ $rootScope . $digest ( ) ;
1099+ assignElements ( wrapElement ) ;
1100+ } ) ) ;
1101+
1102+ it ( 'to display the correct value in input' , function ( ) {
1103+ expect ( inputEl . val ( ) ) . toBe ( '30-September-2010' ) ;
1104+ } ) ;
1105+
1106+ it ( 'updates the input when a day is clicked' , function ( ) {
1107+ clickOption ( 2 , 3 ) ;
1108+ expect ( inputEl . val ( ) ) . toBe ( '15-September-2010' ) ;
1109+ expect ( $rootScope . date ) . toEqual ( new Date ( 'September 15, 2010 15:30:00' ) ) ;
1110+ } ) ;
1111+
1112+ it ( 'updates the input correctly when model changes' , function ( ) {
1113+ $rootScope . date = new Date ( "August 11, 2013 09:09:00" ) ;
1114+ $rootScope . $digest ( ) ;
1115+ expect ( inputEl . val ( ) ) . toBe ( '11-August-2013' ) ;
1116+ } ) ;
1117+
1118+ it ( 'updates the input correctly when format changes' , function ( ) {
1119+ $rootScope . format = 'dd/MM/yyyy' ;
1120+ $rootScope . $digest ( ) ;
1121+ expect ( inputEl . val ( ) ) . toBe ( '30/09/2010' ) ;
1122+ } ) ;
1123+ } ) ;
1124+
1125+ describe ( '`close-on-date-selection` attribute' , function ( ) {
1126+ beforeEach ( inject ( function ( ) {
1127+ $rootScope . close = false ;
1128+ var wrapElement = $compile ( '<div><input ng-model="date" datepicker-popup close-on-date-selection="close" is-open="true"><div>' ) ( $rootScope ) ;
1129+ $rootScope . $digest ( ) ;
1130+ assignElements ( wrapElement ) ;
1131+ } ) ) ;
1132+
1133+ it ( 'dpes not close the dropdown when a day is clicked' , function ( ) {
1134+ clickOption ( 2 , 3 ) ;
1135+ expect ( dropdownEl . css ( 'display' ) ) . not . toBe ( 'none' ) ;
1136+ } ) ;
1137+ } ) ;
1138+
10941139 describe ( 'button bar' , function ( ) {
10951140 var buttons ;
10961141 beforeEach ( inject ( function ( ) {
0 commit comments