@@ -1375,6 +1375,93 @@ describe('ui-select tests', function() {
1375
1375
expect ( scope . $model ) . toBe ( scope . $item ) ;
1376
1376
} ) ;
1377
1377
1378
+ it ( 'should invoke open callback on open' , function ( ) {
1379
+
1380
+ scope . onOpenFn = function ( ) { } ;
1381
+ spyOn ( scope , 'onOpenFn' ) ;
1382
+
1383
+ var el = compileTemplate (
1384
+ '<ui-select on-open="onOpenFn($item, $model)" ng-model="selection.selected"> \
1385
+ <ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
1386
+ <ui-select-choices repeat="person.name as person in people | filter: $select.search"> \
1387
+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
1388
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
1389
+ </ui-select-choices> \
1390
+ </ui-select>'
1391
+ ) ;
1392
+
1393
+ openDropdown ( el ) ;
1394
+
1395
+ expect ( scope . onOpenFn ) . toHaveBeenCalled ( ) ;
1396
+ expect ( scope . onOpenFn . calls . count ( ) ) . not . toBe ( 2 ) ;
1397
+
1398
+ } ) ;
1399
+
1400
+ it ( 'should pass params to the open callback' , function ( ) {
1401
+
1402
+ scope . onOpenFn = function ( ) { } ;
1403
+ spyOn ( scope , 'onOpenFn' ) ;
1404
+
1405
+ var el = compileTemplate (
1406
+ '<ui-select on-open="onOpenFn($item, $model)" ng-model="selection.selected"> \
1407
+ <ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
1408
+ <ui-select-choices repeat="person.name as person in people | filter: $select.search"> \
1409
+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
1410
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
1411
+ </ui-select-choices> \
1412
+ </ui-select>'
1413
+ ) ;
1414
+
1415
+ clickItem ( el , 'Samantha' ) ;
1416
+
1417
+ expect ( scope . onOpenFn ) . toHaveBeenCalledWith ( undefined , undefined ) ;
1418
+
1419
+ } ) ;
1420
+
1421
+ it ( 'should invoke close callback on close' , function ( ) {
1422
+
1423
+ scope . onCloseFn = function ( ) { } ;
1424
+ spyOn ( scope , 'onCloseFn' ) ;
1425
+
1426
+ var el = compileTemplate (
1427
+ '<ui-select on-close="onCloseFn($item, $model)" ng-model="selection.selected"> \
1428
+ <ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
1429
+ <ui-select-choices repeat="person.name as person in people | filter: $select.search"> \
1430
+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
1431
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
1432
+ </ui-select-choices> \
1433
+ </ui-select>'
1434
+ ) ;
1435
+
1436
+ openDropdown ( el ) ;
1437
+ closeDropdown ( el ) ;
1438
+
1439
+ expect ( scope . onCloseFn ) . toHaveBeenCalled ( ) ;
1440
+ expect ( scope . onCloseFn . calls . count ( ) ) . not . toBe ( 2 ) ;
1441
+
1442
+ } ) ;
1443
+
1444
+ it ( 'should pass params to the close callback' , function ( ) {
1445
+
1446
+ scope . onCloseFn = function ( ) { } ;
1447
+ spyOn ( scope , 'onCloseFn' ) ;
1448
+
1449
+ var el = compileTemplate (
1450
+ '<ui-select on-close="onCloseFn($item, $model)" ng-model="selection.selected"> \
1451
+ <ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
1452
+ <ui-select-choices repeat="person.name as person in people | filter: $select.search"> \
1453
+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
1454
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
1455
+ </ui-select-choices> \
1456
+ </ui-select>'
1457
+ ) ;
1458
+
1459
+ clickItem ( el , 'Samantha' ) ;
1460
+
1461
+ expect ( scope . onCloseFn ) . toHaveBeenCalledWith ( scope . people [ 5 ] , 'Samantha' ) ;
1462
+
1463
+ } ) ;
1464
+
1378
1465
it ( 'should allow creating tag in single select mode with tagging enabled' , function ( ) {
1379
1466
1380
1467
scope . taggingFunc = function ( name ) {
@@ -2527,7 +2614,7 @@ describe('ui-select tests', function() {
2527
2614
expect ( el . scope ( ) . $select . items [ 1 ] ) . toEqual ( jasmine . objectContaining ( { name :
'Amalie' , email :
'[email protected] ' } ) ) ;
2528
2615
} ) ;
2529
2616
2530
-
2617
+
2531
2618
it ( 'should have tolerance for undefined values' , function ( ) {
2532
2619
2533
2620
scope . modelValue = undefined ;
@@ -2563,7 +2650,7 @@ describe('ui-select tests', function() {
2563
2650
2564
2651
expect ( $ ( el ) . scope ( ) . $select . selected ) . toEqual ( [ ] ) ;
2565
2652
} ) ;
2566
-
2653
+
2567
2654
it ( 'should allow paste tag from clipboard' , function ( ) {
2568
2655
scope . taggingFunc = function ( name ) {
2569
2656
return {
0 commit comments