@@ -1944,34 +1944,67 @@ describe('ui-select tests', function() {
1944
1944
1945
1945
} ) ;
1946
1946
1947
- it ( 'should watch changes for $select.selected and update formatted value correctly' , function ( ) {
1947
+ it ( 'should watch changes for $select.selected and update formatted value correctly' , function ( ) {
1948
1948
1949
- scope . selection . selectedMultiple = [ '[email protected] ' , '[email protected] ' ] ;
1949
+ scope . selection . selectedMultiple = [ '[email protected] ' , '[email protected] ' ] ;
1950
1950
1951
- var el = compileTemplate (
1952
- '<ui-select multiple ng-model="selection.selectedMultiple" theme="bootstrap" style="width: 800px;"> \
1953
- <ui-select-match placeholder="Pick one...">{{$item.name}} <{{$item.email}}></ui-select-match> \
1954
- <ui-select-choices repeat="person.email as person in people | filter: $select.search"> \
1955
- <div ng-bind-html="person.name | highlight: $select.search"></div> \
1956
- <div ng-bind-html="person.email | highlight: $select.search"></div> \
1957
- </ui-select-choices> \
1958
- </ui-select> \
1959
- '
1960
- ) ;
1951
+ var el = compileTemplate (
1952
+ '<ui-select multiple ng-model="selection.selectedMultiple" theme="bootstrap" style="width: 800px;"> \
1953
+ <ui-select-match placeholder="Pick one...">{{$item.name}} <{{$item.email}}></ui-select-match> \
1954
+ <ui-select-choices repeat="person.email as person in people | filter: $select.search"> \
1955
+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
1956
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
1957
+ </ui-select-choices> \
1958
+ </ui-select> \
1959
+ '
1960
+ ) ;
1961
1961
1962
- var el2 = compileTemplate ( '<span class="resultDiv" ng-bind="selection.selectedMultiple"></span>' ) ;
1962
+ var el2 = compileTemplate ( '<span class="resultDiv" ng-bind="selection.selectedMultiple"></span>' ) ;
1963
1963
1964
- expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1965
-
1964
+ expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1965
+
1966
1966
1967
- clickItem ( el , 'Nicole' ) ;
1967
+ clickItem ( el , 'Nicole' ) ;
1968
1968
1969
- expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1970
-
1969
+ expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1970
+
1971
1971
1972
- expect ( scope . selection . selectedMultiple . length ) . toBe ( 3 ) ;
1972
+ expect ( scope . selection . selectedMultiple . length ) . toBe ( 3 ) ;
1973
1973
1974
- } ) ;
1974
+ } ) ;
1975
+
1976
+ it ( 'should ensure the multiple selection limit is respected' , function ( ) {
1977
+
1978
+ scope . selection . selectedMultiple = [ '[email protected] ' ] ;
1979
+
1980
+ var el = compileTemplate (
1981
+ '<ui-select multiple limit="2" ng-model="selection.selectedMultiple" theme="bootstrap" style="width: 800px;"> \
1982
+ <ui-select-match placeholder="Pick one...">{{$item.name}} <{{$item.email}}></ui-select-match> \
1983
+ <ui-select-choices repeat="person.email as person in people | filter: $select.search"> \
1984
+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
1985
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
1986
+ </ui-select-choices> \
1987
+ </ui-select> \
1988
+ '
1989
+ ) ;
1990
+
1991
+ var el2 = compileTemplate ( '<span class="resultDiv" ng-bind="selection.selectedMultiple"></span>' ) ;
1992
+
1993
+ expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1994
+ . toBe ( "Wladimir <[email protected] >" ) ;
1995
+
1996
+ clickItem ( el , 'Samantha' ) ;
1997
+ expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1998
+
1999
+
2000
+ clickItem ( el , 'Nicole' ) ;
2001
+
2002
+ expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
2003
+
2004
+
2005
+ expect ( scope . selection . selectedMultiple . length ) . toBe ( 2 ) ;
2006
+
2007
+ } ) ;
1975
2008
1976
2009
it ( 'should change viewvalue only once when updating modelvalue' , function ( ) {
1977
2010
0 commit comments