@@ -15,7 +15,28 @@ describe('ui-select tests', function() {
15
15
Escape : 27
16
16
} ;
17
17
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' ) ) ;
19
40
beforeEach ( inject ( function ( _$rootScope_ , _$compile_ , _$timeout_ , _$injector_ ) {
20
41
$rootScope = _$rootScope_ ;
21
42
scope = $rootScope . $new ( ) ;
@@ -186,6 +207,13 @@ describe('ui-select tests', function() {
186
207
expect ( getMatchLabel ( el ) ) . toEqual ( 'Samantha' ) ;
187
208
} ) ;
188
209
210
+ it ( 'should utilize wrapper directive ng-model' , function ( ) {
211
+ var el = compileTemplate ( '<wrapper-ui-select ng-model="selection.selected"/>' ) ;
212
+ scope . selection . selected = { name : 'Samantha' , email : 'something different than array source' , group : 'bar' , age : 30 } ;
213
+ scope . $digest ( ) ;
214
+ expect ( $ ( el ) . find ( '.ui-select-container > .ui-select-match > button:first > span[ng-transclude]:not(.ng-hide)' ) . text ( ) ) . toEqual ( 'Samantha' ) ;
215
+ } ) ;
216
+
189
217
it ( 'should display the choices when activated' , function ( ) {
190
218
var el = createUiSelect ( ) ;
191
219
0 commit comments