@@ -728,6 +728,63 @@ describe('ui-select tests', function() {
728
728
729
729
} ) ;
730
730
731
+ it ( 'should invoke remove callback on remove' , function ( ) {
732
+
733
+ scope . onRemoveFn = function ( $item , $model , $label ) {
734
+ scope . $item = $item ;
735
+ scope . $model = $model ;
736
+ } ;
737
+
738
+ var el = compileTemplate (
739
+ '<ui-select multiple on-remove="onRemoveFn($item, $model)" ng-model="selection.selected"> \
740
+ <ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
741
+ <ui-select-choices repeat="person.name as person in people | filter: $select.search"> \
742
+ <div ng-bind-html="person.name" | highlight: $select.search"></div> \
743
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
744
+ </ui-select-choices> \
745
+ </ui-select>'
746
+ ) ;
747
+
748
+ expect ( scope . $item ) . toBeFalsy ( ) ;
749
+ expect ( scope . $model ) . toBeFalsy ( ) ;
750
+
751
+ clickItem ( el , 'Samantha' ) ;
752
+ clickItem ( el , 'Adrian' ) ;
753
+ el . find ( '.ui-select-match-item' ) . first ( ) . find ( '.ui-select-match-close' ) . click ( ) ;
754
+
755
+ expect ( scope . $item ) . toBe ( scope . people [ 5 ] ) ;
756
+ expect ( scope . $model ) . toBe ( 'Samantha' ) ;
757
+
758
+ } ) ;
759
+
760
+ it ( 'should set $item & $model correctly when invoking callback on remove and no single prop. binding' , function ( ) {
761
+
762
+ scope . onRemoveFn = function ( $item , $model , $label ) {
763
+ scope . $item = $item ;
764
+ scope . $model = $model ;
765
+ } ;
766
+
767
+ var el = compileTemplate (
768
+ '<ui-select multiple on-remove="onRemoveFn($item, $model)" ng-model="selection.selected"> \
769
+ <ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
770
+ <ui-select-choices repeat="person in people | filter: $select.search"> \
771
+ <div ng-bind-html="person.name" | highlight: $select.search"></div> \
772
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
773
+ </ui-select-choices> \
774
+ </ui-select>'
775
+ ) ;
776
+
777
+ expect ( scope . $item ) . toBeFalsy ( ) ;
778
+ expect ( scope . $model ) . toBeFalsy ( ) ;
779
+
780
+ clickItem ( el , 'Samantha' ) ;
781
+ clickItem ( el , 'Adrian' ) ;
782
+ el . find ( '.ui-select-match-item' ) . first ( ) . find ( '.ui-select-match-close' ) . click ( ) ;
783
+
784
+ expect ( scope . $item ) . toBe ( scope . people [ 5 ] ) ;
785
+ expect ( scope . $model ) . toBe ( scope . $item ) ;
786
+ } ) ;
787
+
731
788
it ( 'should append/transclude content (with correct scope) that users add at <match> tag' , function ( ) {
732
789
733
790
var el = compileTemplate (
0 commit comments