@@ -850,6 +850,36 @@ describe('select', function() {
850
850
expect ( element . val ( ) ) . toEqual ( '4' ) ;
851
851
} ) ;
852
852
853
+ it ( 'should bind to scope value and track/identify objects using a valueFn' , function ( ) {
854
+ createSelect ( {
855
+ 'ng-model' : 'selected' ,
856
+ 'ng-options' : 'item.id as item.name for item in values track by item.id'
857
+ } ) ;
858
+
859
+ scope . $apply ( function ( ) {
860
+ scope . values = [ { id : 1 , name : 'first' } ,
861
+ { id : 2 , name : 'second' } ,
862
+ { id : 3 , name : 'third' } ,
863
+ { id : 4 , name : 'forth' } ] ;
864
+ scope . selected = 2 ;
865
+ } ) ;
866
+
867
+ expect ( element . val ( ) ) . toEqual ( '2' ) ;
868
+
869
+ var first = jqLite ( element . find ( 'option' ) [ 0 ] ) ;
870
+ expect ( first . text ( ) ) . toEqual ( 'first' ) ;
871
+ expect ( first . attr ( 'value' ) ) . toEqual ( '1' ) ;
872
+ var forth = jqLite ( element . find ( 'option' ) [ 3 ] ) ;
873
+ expect ( forth . text ( ) ) . toEqual ( 'forth' ) ;
874
+ expect ( forth . attr ( 'value' ) ) . toEqual ( '4' ) ;
875
+
876
+ scope . $apply ( function ( ) {
877
+ scope . selected = scope . values [ 3 ] ;
878
+ } ) ;
879
+
880
+ expect ( element . val ( ) ) . toEqual ( '4' ) ;
881
+ } ) ;
882
+
853
883
854
884
it ( 'should bind to scope value through experession' , function ( ) {
855
885
createSelect ( {
0 commit comments