@@ -295,7 +295,7 @@ describe('ui-select tests', function() {
295
295
} ) . toThrow ( new Error ( '[ui.select:transcluded] Expected 1 .ui-select-match but got \'0\'.' ) ) ;
296
296
} ) ;
297
297
298
- it ( 'should parse and format the model correctly using alias' , function ( ) {
298
+ it ( 'should format the model correctly using alias' , function ( ) {
299
299
var el = compileTemplate (
300
300
'<ui-select ng-model="selection.selected"> \
301
301
<ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
@@ -309,7 +309,22 @@ describe('ui-select tests', function() {
309
309
expect ( scope . selection . selected ) . toBe ( scope . people [ 5 ] ) ;
310
310
} ) ;
311
311
312
- it ( 'should parse and format the model correctly using property of alias' , function ( ) {
312
+ it ( 'should parse the model correctly using alias' , function ( ) {
313
+ var el = compileTemplate (
314
+ '<ui-select ng-model="selection.selected"> \
315
+ <ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
316
+ <ui-select-choices repeat="person as person in people | filter: $select.search"> \
317
+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
318
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
319
+ </ui-select-choices> \
320
+ </ui-select>'
321
+ ) ;
322
+ scope . selection . selected = scope . people [ 5 ] ;
323
+ scope . $digest ( ) ;
324
+ expect ( getMatchLabel ( el ) ) . toEqual ( 'Samantha' ) ;
325
+ } ) ;
326
+
327
+ it ( 'should format the model correctly using property of alias' , function ( ) {
313
328
var el = compileTemplate (
314
329
'<ui-select ng-model="selection.selected"> \
315
330
<ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
@@ -323,9 +338,46 @@ describe('ui-select tests', function() {
323
338
expect ( scope . selection . selected ) . toBe ( 'Samantha' ) ;
324
339
} ) ;
325
340
326
- it ( 'should parse and format the model correctly without alias' , function ( ) {
341
+ it ( 'should parse the model correctly using property of alias' , function ( ) {
342
+ var el = compileTemplate (
343
+ '<ui-select ng-model="selection.selected"> \
344
+ <ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
345
+ <ui-select-choices repeat="person.name as person in people | filter: $select.search"> \
346
+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
347
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
348
+ </ui-select-choices> \
349
+ </ui-select>'
350
+ ) ;
351
+ scope . selection . selected = 'Samantha' ;
352
+ scope . $digest ( ) ;
353
+ expect ( getMatchLabel ( el ) ) . toEqual ( 'Samantha' ) ;
354
+ } ) ;
355
+
356
+ it ( 'should parse the model correctly using property of alias but passed whole object' , function ( ) {
357
+ var el = compileTemplate (
358
+ '<ui-select ng-model="selection.selected"> \
359
+ <ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
360
+ <ui-select-choices repeat="person.name as person in people | filter: $select.search"> \
361
+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
362
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
363
+ </ui-select-choices> \
364
+ </ui-select>'
365
+ ) ;
366
+ scope . selection . selected = scope . people [ 5 ] ;
367
+ scope . $digest ( ) ;
368
+ expect ( getMatchLabel ( el ) ) . toEqual ( 'Samantha' ) ;
369
+ } ) ;
370
+
371
+ it ( 'should format the model correctly without alias' , function ( ) {
327
372
var el = createUiSelect ( ) ;
328
373
clickItem ( el , 'Samantha' ) ;
329
374
expect ( scope . selection . selected ) . toBe ( scope . people [ 5 ] ) ;
330
375
} ) ;
376
+
377
+ it ( 'should parse the model correctly without alias' , function ( ) {
378
+ var el = createUiSelect ( ) ;
379
+ scope . selection . selected = scope . people [ 5 ] ;
380
+ scope . $digest ( ) ;
381
+ expect ( getMatchLabel ( el ) ) . toEqual ( 'Samantha' ) ;
382
+ } ) ;
331
383
} ) ;
0 commit comments