@@ -1754,34 +1754,67 @@ describe('ui-select tests', function() {
1754
1754
1755
1755
} ) ;
1756
1756
1757
- it ( 'should watch changes for $select.selected and update formatted value correctly' , function ( ) {
1757
+ it ( 'should watch changes for $select.selected and update formatted value correctly' , function ( ) {
1758
1758
1759
- scope . selection . selectedMultiple = [ '[email protected] ' , '[email protected] ' ] ;
1759
+ scope . selection . selectedMultiple = [ '[email protected] ' , '[email protected] ' ] ;
1760
1760
1761
- var el = compileTemplate (
1762
- '<ui-select multiple ng-model="selection.selectedMultiple" theme="bootstrap" style="width: 800px;"> \
1763
- <ui-select-match placeholder="Pick one...">{{$item.name}} <{{$item.email}}></ui-select-match> \
1764
- <ui-select-choices repeat="person.email as person in people | filter: $select.search"> \
1765
- <div ng-bind-html="person.name | highlight: $select.search"></div> \
1766
- <div ng-bind-html="person.email | highlight: $select.search"></div> \
1767
- </ui-select-choices> \
1768
- </ui-select> \
1769
- '
1770
- ) ;
1761
+ var el = compileTemplate (
1762
+ '<ui-select multiple ng-model="selection.selectedMultiple" theme="bootstrap" style="width: 800px;"> \
1763
+ <ui-select-match placeholder="Pick one...">{{$item.name}} <{{$item.email}}></ui-select-match> \
1764
+ <ui-select-choices repeat="person.email as person in people | filter: $select.search"> \
1765
+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
1766
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
1767
+ </ui-select-choices> \
1768
+ </ui-select> \
1769
+ '
1770
+ ) ;
1771
1771
1772
- var el2 = compileTemplate ( '<span class="resultDiv" ng-bind="selection.selectedMultiple"></span>' ) ;
1772
+ var el2 = compileTemplate ( '<span class="resultDiv" ng-bind="selection.selectedMultiple"></span>' ) ;
1773
1773
1774
- expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1775
-
1774
+ expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1775
+
1776
1776
1777
- clickItem ( el , 'Nicole' ) ;
1777
+ clickItem ( el , 'Nicole' ) ;
1778
1778
1779
- expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1780
-
1779
+ expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1780
+
1781
1781
1782
- expect ( scope . selection . selectedMultiple . length ) . toBe ( 3 ) ;
1782
+ expect ( scope . selection . selectedMultiple . length ) . toBe ( 3 ) ;
1783
1783
1784
- } ) ;
1784
+ } ) ;
1785
+
1786
+ it ( 'should ensure the multiple selection limit is respected' , function ( ) {
1787
+
1788
+ scope . selection . selectedMultiple = [ '[email protected] ' ] ;
1789
+
1790
+ var el = compileTemplate (
1791
+ '<ui-select multiple limit="2" ng-model="selection.selectedMultiple" theme="bootstrap" style="width: 800px;"> \
1792
+ <ui-select-match placeholder="Pick one...">{{$item.name}} <{{$item.email}}></ui-select-match> \
1793
+ <ui-select-choices repeat="person.email as person in people | filter: $select.search"> \
1794
+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
1795
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
1796
+ </ui-select-choices> \
1797
+ </ui-select> \
1798
+ '
1799
+ ) ;
1800
+
1801
+ var el2 = compileTemplate ( '<span class="resultDiv" ng-bind="selection.selectedMultiple"></span>' ) ;
1802
+
1803
+ expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1804
+ . toBe ( "Wladimir <[email protected] >" ) ;
1805
+
1806
+ clickItem ( el , 'Samantha' ) ;
1807
+ expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1808
+
1809
+
1810
+ clickItem ( el , 'Nicole' ) ;
1811
+
1812
+ expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1813
+
1814
+
1815
+ expect ( scope . selection . selectedMultiple . length ) . toBe ( 2 ) ;
1816
+
1817
+ } ) ;
1785
1818
1786
1819
it ( 'should change viewvalue only once when updating modelvalue' , function ( ) {
1787
1820
0 commit comments