@@ -1264,10 +1264,11 @@ describe('datepicker directive with empty initial state', function () {
1264
1264
} ) ;
1265
1265
} ) ;
1266
1266
1267
- describe ( '' , function ( ) {
1267
+ describe ( 'customise button group ' , function ( ) {
1268
1268
var $rootScope , element , $httpBackend ;
1269
1269
1270
1270
beforeEach ( module ( 'ui.bootstrap.datepicker' ) ) ;
1271
+ beforeEach ( module ( 'template/datepicker/datepicker.html' ) ) ;
1271
1272
beforeEach ( module ( 'template/datepicker/popup.html' ) ) ;
1272
1273
beforeEach ( inject ( function ( _$compile_ , _$rootScope_ , _$httpBackend_ ) {
1273
1274
$compile = _$compile_ ;
@@ -1276,8 +1277,9 @@ describe('',function(){
1276
1277
} ) ) ;
1277
1278
1278
1279
it ( "should send request to get customer template" , function ( ) {
1280
+ $rootScope . onCustomerButtonClick = function ( ) { } ;
1279
1281
var templateUrl = "test.html" ,
1280
- html = '<div><button type="button" ng-click="selectDate (\'2012-01-01 \')">Next financial day</button></div>' ;
1282
+ html = '<div><button type="button" ng-click="onCustomerButtonClick (\'next financial \')">Next financial day</button></div>' ;
1281
1283
$httpBackend . whenGET ( templateUrl ) . respond ( 200 , html ) ;
1282
1284
element = $compile ( '<datepicker-popup-wrap button-group-template-url="' + templateUrl + '"></datepicker-popup-wrap>' ) ( $rootScope ) ;
1283
1285
$rootScope . $digest ( ) ;
@@ -1286,4 +1288,20 @@ describe('',function(){
1286
1288
expect ( element . find ( 'button' ) . text ( ) ) . toEqual ( "Next financial day" ) ;
1287
1289
} ) ;
1288
1290
1291
+ it ( "should send customer click event" , function ( ) {
1292
+ $rootScope . onCustomerButtonClick = function ( ) { } ;
1293
+ spyOn ( $rootScope , "onCustomerButtonClick" ) . andCallThrough ( ) ;
1294
+ var templateUrl = "test.html" ,
1295
+ html = '<div><button class="customerBtn" type="button" ng-click="onCustomerButtonClick(\'next financial\')">Next financial day</button></div>' ;
1296
+ $httpBackend . whenGET ( templateUrl ) . respond ( 200 , html ) ;
1297
+ element = $compile ( '<div><input type="text" datepicker-popup="" on-customer-button-click="onCustomerButtonClick($param);" ng-model="dt" button-group-template-url="' + templateUrl + '"/></div>' ) ( $rootScope ) ;
1298
+ $rootScope . $digest ( ) ;
1299
+ $httpBackend . flush ( ) ;
1300
+
1301
+ element . find ( '.customerBtn' ) . click ( ) ;
1302
+ $rootScope . $digest ( ) ;
1303
+ expect ( $rootScope . onCustomerButtonClick ) . toHaveBeenCalledWith ( [ 'next financial' ] ) ;
1304
+ } ) ;
1305
+
1306
+
1289
1307
} ) ;
0 commit comments