@@ -1610,42 +1610,42 @@ describe('ui-select tests', function() {
1610
1610
expect ( el . find ( '.ui-select-match-item' ) . length ) . toBe ( 0 ) ;
1611
1611
} ) ;
1612
1612
1613
- it ( 'should render intial state with data-multiple attribute' , function ( ) {
1614
- // ensure match template has been loaded by having more than one selection
1615
- scope . selection . selectedMultiple = [ scope . people [ 0 ] , scope . people [ 1 ] ] ;
1616
-
1613
+ it ( 'should render intial state with data-multiple attribute' , function ( ) {
1614
+ // ensure match template has been loaded by having more than one selection
1615
+ scope . selection . selectedMultiple = [ scope . people [ 0 ] , scope . people [ 1 ] ] ;
1616
+
1617
1617
var el = compileTemplate (
1618
1618
'<ui-select data-multiple ng-model="selection.selectedMultiple" theme="bootstrap" style="width: 800px;"> \
1619
1619
<ui-select-match placeholder="Pick one...">{{$item.name}} <{{$item.email}}></ui-select-match> \
1620
1620
<ui-select-choices repeat="person in people | filter: $select.search"> \
1621
1621
<div ng-bind-html="person.name | highlight: $select.search"></div> \
1622
1622
<div ng-bind-html="person.email | highlight: $select.search"></div> \
1623
1623
</ui-select-choices> \
1624
- </ui-select>'
1625
- ) ;
1626
-
1624
+ </ui-select>'
1625
+ ) ;
1626
+
1627
1627
expect ( el ) . toHaveClass ( 'ui-select-multiple' ) ;
1628
1628
expect ( el . scope ( ) . $select . selected . length ) . toBe ( 2 ) ;
1629
- expect ( el . find ( '.ui-select-match-item' ) . length ) . toBe ( 2 ) ;
1629
+ expect ( el . find ( '.ui-select-match-item' ) . length ) . toBe ( 2 ) ;
1630
1630
} ) ;
1631
1631
1632
- it ( 'should render intial state with x-multiple attribute' , function ( ) {
1633
- // ensure match template has been loaded by having more than one selection
1634
- scope . selection . selectedMultiple = [ scope . people [ 0 ] , scope . people [ 1 ] ] ;
1635
-
1632
+ it ( 'should render intial state with x-multiple attribute' , function ( ) {
1633
+ // ensure match template has been loaded by having more than one selection
1634
+ scope . selection . selectedMultiple = [ scope . people [ 0 ] , scope . people [ 1 ] ] ;
1635
+
1636
1636
var el = compileTemplate (
1637
1637
'<ui-select x-multiple ng-model="selection.selectedMultiple" theme="bootstrap" style="width: 800px;"> \
1638
1638
<ui-select-match placeholder="Pick one...">{{$item.name}} <{{$item.email}}></ui-select-match> \
1639
1639
<ui-select-choices repeat="person in people | filter: $select.search"> \
1640
1640
<div ng-bind-html="person.name | highlight: $select.search"></div> \
1641
1641
<div ng-bind-html="person.email | highlight: $select.search"></div> \
1642
1642
</ui-select-choices> \
1643
- </ui-select>'
1644
- ) ;
1645
-
1643
+ </ui-select>'
1644
+ ) ;
1645
+
1646
1646
expect ( el ) . toHaveClass ( 'ui-select-multiple' ) ;
1647
1647
expect ( el . scope ( ) . $select . selected . length ) . toBe ( 2 ) ;
1648
- expect ( el . find ( '.ui-select-match-item' ) . length ) . toBe ( 2 ) ;
1648
+ expect ( el . find ( '.ui-select-match-item' ) . length ) . toBe ( 2 ) ;
1649
1649
} ) ;
1650
1650
1651
1651
it ( 'should set model as an empty array if ngModel isnt defined after an item is selected' , function ( ) {
@@ -2206,6 +2206,44 @@ describe('ui-select tests', function() {
2206
2206
expect ( el . scope ( ) . $select . multiple ) . toBe ( true ) ;
2207
2207
} ) ;
2208
2208
2209
+ it ( 'should have tolerance for undefined values' , function ( ) {
2210
+
2211
+ scope . modelValue = undefined ;
2212
+
2213
+ var el = compileTemplate (
2214
+ '<ui-select multiple ng-model="modelValue" theme="bootstrap" style="width: 800px;"> \
2215
+ <ui-select-match placeholder="Pick one...">{{$item.name}} <{{$item.email}}></ui-select-match> \
2216
+ <ui-select-choices repeat="person.email as person in people | filter: $select.search"> \
2217
+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
2218
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
2219
+ </ui-select-choices> \
2220
+ </ui-select> \
2221
+ '
2222
+ ) ;
2223
+
2224
+ expect ( $ ( el ) . scope ( ) . $select . selected ) . toEqual ( [ ] ) ;
2225
+
2226
+ } ) ;
2227
+
2228
+ it ( 'should have tolerance for null values' , function ( ) {
2229
+
2230
+ scope . modelValue = null ;
2231
+
2232
+ var el = compileTemplate (
2233
+ '<ui-select multiple ng-model="modelValue" theme="bootstrap" style="width: 800px;"> \
2234
+ <ui-select-match placeholder="Pick one...">{{$item.name}} <{{$item.email}}></ui-select-match> \
2235
+ <ui-select-choices repeat="person.email as person in people | filter: $select.search"> \
2236
+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
2237
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
2238
+ </ui-select-choices> \
2239
+ </ui-select> \
2240
+ '
2241
+ ) ;
2242
+
2243
+ expect ( $ ( el ) . scope ( ) . $select . selected ) . toEqual ( [ ] ) ;
2244
+
2245
+ } ) ;
2246
+
2209
2247
it ( 'should allow paste tag from clipboard' , function ( ) {
2210
2248
scope . taggingFunc = function ( name ) {
2211
2249
return {
0 commit comments