@@ -15,7 +15,28 @@ describe('ui-select tests', function() {
1515 Escape : 27
1616 } ;
1717
18- beforeEach ( module ( 'ngSanitize' , 'ui.select' ) ) ;
18+ //create a directive that wraps ui-select
19+ angular . module ( 'wrapperDirective' , [ 'ui.select' ] ) ;
20+ angular . module ( 'wrapperDirective' ) . directive ( 'wrapperUiSelect' , function ( ) {
21+ return {
22+ restrict : 'EA' ,
23+ template : '<ui-select> \
24+ <ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
25+ <ui-select-choices repeat="person in people | filter: $select.search"> \
26+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
27+ </ui-select-choices> \
28+ </ui-select>' ,
29+ require : 'ngModel' ,
30+ scope : true ,
31+
32+ link : function ( scope , element , attrs , ctrl ) {
33+
34+ }
35+ }
36+
37+ } ) ;
38+
39+ beforeEach ( module ( 'ngSanitize' , 'ui.select' , 'wrapperDirective' ) ) ;
1940 beforeEach ( inject ( function ( _$rootScope_ , _$compile_ , _$timeout_ , _$injector_ ) {
2041 $rootScope = _$rootScope_ ;
2142 scope = $rootScope . $new ( ) ;
@@ -174,6 +195,13 @@ describe('ui-select tests', function() {
174195 expect ( getMatchLabel ( el ) ) . toEqual ( 'Samantha' ) ;
175196 } ) ;
176197
198+ it ( 'should utilize wrapper directive ng-model' , function ( ) {
199+ var el = compileTemplate ( '<wrapper-ui-select ng-model="selection.selected"/>' ) ;
200+ scope . selection . selected = { name : 'Samantha' , email : 'something different than array source' , group : 'bar' , age : 30 } ;
201+ scope . $digest ( ) ;
202+ expect ( $ ( el ) . find ( '.ui-select-container > .ui-select-match > button:first > span[ng-transclude]:not(.ng-hide)' ) . text ( ) ) . toEqual ( 'Samantha' ) ;
203+ } ) ;
204+
177205 it ( 'should display the choices when activated' , function ( ) {
178206 var el = createUiSelect ( ) ;
179207
0 commit comments