@@ -1754,34 +1754,67 @@ describe('ui-select tests', function() {
17541754
17551755 } ) ;
17561756
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 ( ) {
17581758
1759- scope . selection . selectedMultiple = [ 'wladimir@email.com' , 'samantha@email.com' ] ;
1759+ scope . selection . selectedMultiple = [ 'wladimir@email.com' , 'samantha@email.com' ] ;
17601760
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+ ) ;
17711771
1772- var el2 = compileTemplate ( '<span class="resultDiv" ng-bind="selection.selectedMultiple"></span>' ) ;
1772+ var el2 = compileTemplate ( '<span class="resultDiv" ng-bind="selection.selectedMultiple"></span>' ) ;
17731773
1774- expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1775- . toBe ( "Wladimir <wladimir@email.com>Samantha <samantha@email.com>" ) ;
1774+ expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1775+ . toBe ( "Wladimir <wladimir@email.com>Samantha <samantha@email.com>" ) ;
17761776
1777- clickItem ( el , 'Nicole' ) ;
1777+ clickItem ( el , 'Nicole' ) ;
17781778
1779- expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1780- . toBe ( "Wladimir <wladimir@email.com>Samantha <samantha@email.com>Nicole <nicole@email.com>" ) ;
1779+ expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1780+ . toBe ( "Wladimir <wladimir@email.com>Samantha <samantha@email.com>Nicole <nicole@email.com>" ) ;
17811781
1782- expect ( scope . selection . selectedMultiple . length ) . toBe ( 3 ) ;
1782+ expect ( scope . selection . selectedMultiple . length ) . toBe ( 3 ) ;
17831783
1784- } ) ;
1784+ } ) ;
1785+
1786+ it ( 'should ensure the multiple selection limit is respected' , function ( ) {
1787+
1788+ scope . selection . selectedMultiple = [ 'wladimir@email.com' ] ;
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 <wladimir@email.com>" ) ;
1805+
1806+ clickItem ( el , 'Samantha' ) ;
1807+ expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1808+ . toBe ( "Wladimir <wladimir@email.com>Samantha <samantha@email.com>" ) ;
1809+
1810+ clickItem ( el , 'Nicole' ) ;
1811+
1812+ expect ( el . find ( '.ui-select-match-item [uis-transclude-append]:not(.ng-hide)' ) . text ( ) )
1813+ . toBe ( "Wladimir <wladimir@email.com>Samantha <samantha@email.com>" ) ;
1814+
1815+ expect ( scope . selection . selectedMultiple . length ) . toBe ( 2 ) ;
1816+
1817+ } ) ;
17851818
17861819 it ( 'should change viewvalue only once when updating modelvalue' , function ( ) {
17871820
0 commit comments