@@ -1427,7 +1427,7 @@ describe('ui-select tests', function() {
1427
1427
expect ( $ ( el ) . scope ( ) . $select . selected ) . toEqual ( [ 'idontexist' ] ) ;
1428
1428
} ) ;
1429
1429
1430
- it ( 'should remove a choice when remove-selected is not given (default is true)' , function ( ) {
1430
+ it ( 'should remove a choice when multiple and remove-selected is not given (default is true)' , function ( ) {
1431
1431
1432
1432
var el = compileTemplate (
1433
1433
'<ui-select multiple ng-model="selection.selected"> \
@@ -1453,6 +1453,31 @@ describe('ui-select tests', function() {
1453
1453
} ) ;
1454
1454
} ) ;
1455
1455
1456
+ it ( 'should not remove a pre-selected choice when not multiple and remove-selected is not given (default is true)' , function ( ) {
1457
+ scope . selection . selected = scope . people [ 5 ] ; // Samantha
1458
+
1459
+ var el = compileTemplate (
1460
+ '<ui-select ng-model="selection.selected"> \
1461
+ <ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
1462
+ <ui-select-choices repeat="person in people | filter: $select.search"> \
1463
+ <div class="person-name" ng-bind-html="person.name" | highlight: $select.search"></div> \
1464
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
1465
+ </ui-select-choices> \
1466
+ </ui-select>'
1467
+ ) ;
1468
+
1469
+ expect ( getMatchLabel ( el ) ) . toEqual ( "Samantha" ) ;
1470
+ openDropdown ( el ) ;
1471
+
1472
+ var choicesEls = $ ( el ) . find ( '.ui-select-choices-row' ) ;
1473
+ expect ( choicesEls . length ) . toEqual ( 8 ) ;
1474
+
1475
+ [ 'Adam' , 'Amalie' , 'Estefanía' , 'Adrian' , 'Wladimir' , 'Samantha' , 'Nicole' , 'Natasha' ] . forEach ( function ( name , index ) {
1476
+ expect ( $ ( choicesEls [ index ] ) . hasClass ( 'disabled' ) ) . toBeFalsy ( ) ;
1477
+ expect ( $ ( choicesEls [ index ] ) . find ( '.person-name' ) . text ( ) ) . toEqual ( name ) ;
1478
+ } ) ;
1479
+ } ) ;
1480
+
1456
1481
it ( 'should disable a choice instead of removing it when remove-selected is false' , function ( ) {
1457
1482
1458
1483
var el = compileTemplate (
0 commit comments