@@ -1025,6 +1025,58 @@ describe('ui-select tests', function() {
1025
1025
expect ( scope . $model ) . toBe ( scope . $item ) ;
1026
1026
} ) ;
1027
1027
1028
+ it ( 'should allow creating tag in single select mode with tagging enabled' , function ( ) {
1029
+
1030
+ scope . taggingFunc = function ( name ) {
1031
+ return name ;
1032
+ } ;
1033
+
1034
+ var el = compileTemplate (
1035
+ '<ui-select ng-model="selection.selected" tagging="taggingFunc" tagging-label="false"> \
1036
+ <ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
1037
+ <ui-select-choices repeat="person in people | filter: $select.search"> \
1038
+ <div ng-bind-html="person.name" | highlight: $select.search"></div> \
1039
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
1040
+ </ui-select-choices> \
1041
+ </ui-select>'
1042
+ ) ;
1043
+
1044
+ clickMatch ( el ) ;
1045
+
1046
+ var searchInput = el . find ( '.ui-select-search' ) ;
1047
+
1048
+ setSearchText ( el , 'idontexist' ) ;
1049
+
1050
+ triggerKeydown ( searchInput , Key . Enter ) ;
1051
+
1052
+ expect ( $ ( el ) . scope ( ) . $select . selected ) . toEqual ( 'idontexist' ) ;
1053
+ } ) ;
1054
+
1055
+ it ( 'should allow creating tag on ENTER in multiple select mode with tagging enabled, no labels' , function ( ) {
1056
+
1057
+ scope . taggingFunc = function ( name ) {
1058
+ return name ;
1059
+ } ;
1060
+
1061
+ var el = compileTemplate (
1062
+ '<ui-select multiple ng-model="selection.selected" tagging="taggingFunc" tagging-label="false"> \
1063
+ <ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
1064
+ <ui-select-choices repeat="person in people | filter: $select.search"> \
1065
+ <div ng-bind-html="person.name" | highlight: $select.search"></div> \
1066
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
1067
+ </ui-select-choices> \
1068
+ </ui-select>'
1069
+ ) ;
1070
+
1071
+ var searchInput = el . find ( '.ui-select-search' ) ;
1072
+
1073
+ setSearchText ( el , 'idontexist' ) ;
1074
+
1075
+ triggerKeydown ( searchInput , Key . Enter ) ;
1076
+
1077
+ expect ( $ ( el ) . scope ( ) . $select . selected ) . toEqual ( [ 'idontexist' ] ) ;
1078
+ } ) ;
1079
+
1028
1080
it ( 'should append/transclude content (with correct scope) that users add at <match> tag' , function ( ) {
1029
1081
1030
1082
var el = compileTemplate (
0 commit comments