@@ -258,6 +258,68 @@ export function main() {
258258          } ) ; 
259259        } ) . then ( done ) ; 
260260    } ) ; 
261+ 
262+     it ( 'should bind value to model without initial value' ,  ( done : ( )  =>  void )  =>  { 
263+       builder 
264+         . overrideTemplate ( TestApp ,  ` 
265+             <md-radio-group  [(ngModel)]="choice"> 
266+               <md-radio-button [value]="0"></md-radio-button> 
267+               <md-radio-button [value]="1"></md-radio-button> 
268+             </md-radio-group>` ) 
269+         . createAsync ( TestApp ) 
270+         . then ( ( fixture )  =>  { 
271+           fakeAsync ( function ( )  { 
272+             let  buttons  =  fixture . debugElement . queryAll ( By . css ( 'md-radio-button' ) ) ; 
273+             let  group  =  fixture . debugElement . query ( By . css ( 'md-radio-group' ) ) ; 
274+ 
275+             fixture . detectChanges ( ) ; 
276+             expect ( buttons [ 0 ] . componentInstance . checked ) . toBe ( false ) ; 
277+             expect ( buttons [ 1 ] . componentInstance . checked ) . toBe ( false ) ; 
278+             expect ( fixture . componentInstance . choice ) . toBe ( undefined ) ; 
279+ 
280+             group . componentInstance . selected  =  buttons [ 0 ] . componentInstance ; 
281+             fixture . detectChanges ( ) ; 
282+             expect ( isSinglySelected ( buttons [ 0 ] ,  buttons ) ) . toBe ( true ) ; 
283+             expect ( fixture . componentInstance . choice ) . toBe ( 0 ) ; 
284+ 
285+             group . componentInstance . selected  =  buttons [ 1 ] . componentInstance ; 
286+             fixture . detectChanges ( ) ; 
287+             expect ( isSinglySelected ( buttons [ 1 ] ,  buttons ) ) . toBe ( true ) ; 
288+             expect ( fixture . componentInstance . choice ) . toBe ( 1 ) ; 
289+           } ) ; 
290+         } ) . then ( done ) ; 
291+     } ) ; 
292+ 
293+     it ( 'should bind value to model with initial value' ,  ( done : ( )  =>  void )  =>  { 
294+       builder 
295+         . overrideTemplate ( TestAppWithInitialValue ,  ` 
296+             <md-radio-group  [(ngModel)]="choice"> 
297+               <md-radio-button [value]="0"></md-radio-button> 
298+               <md-radio-button [value]="1"></md-radio-button> 
299+             </md-radio-group>` ) 
300+         . createAsync ( TestAppWithInitialValue ) 
301+         . then ( ( fixture )  =>  { 
302+           fakeAsync ( function ( )  { 
303+             let  buttons  =  fixture . debugElement . queryAll ( By . css ( 'md-radio-button' ) ) ; 
304+             let  group  =  fixture . debugElement . query ( By . css ( 'md-radio-group' ) ) ; 
305+ 
306+             fixture . detectChanges ( ) ; 
307+             expect ( isSinglySelected ( buttons [ 1 ] ,  buttons ) ) . toBe ( true ) ; 
308+             expect ( fixture . componentInstance . choice ) . toBe ( 1 ) ; 
309+ 
310+             group . componentInstance . selected  =  buttons [ 0 ] . componentInstance ; 
311+             fixture . detectChanges ( ) ; 
312+             expect ( isSinglySelected ( buttons [ 0 ] ,  buttons ) ) . toBe ( true ) ; 
313+             expect ( fixture . componentInstance . choice ) . toBe ( 0 ) ; 
314+ 
315+             group . componentInstance . selected  =  buttons [ 1 ] . componentInstance ; 
316+             fixture . detectChanges ( ) ; 
317+             expect ( isSinglySelected ( buttons [ 1 ] ,  buttons ) ) . toBe ( true ) ; 
318+             expect ( fixture . componentInstance . choice ) . toBe ( 1 ) ; 
319+           } ) ; 
320+         } ) . then ( done ) ; 
321+     } ) ; 
322+ 
261323  } ) ; 
262324} 
263325
@@ -289,4 +351,16 @@ function createEvent(name: string): Event {
289351  providers : [ MdRadioDispatcher ] , 
290352  template : '' 
291353} ) 
292- class  TestApp  { } 
354+ class  TestApp  { 
355+   choice : number ; 
356+ } 
357+ 
358+ /** Test component. */ 
359+ @Component ( { 
360+   directives : [ MdRadioButton ,  MdRadioGroup ] , 
361+   providers : [ MdRadioDispatcher ] , 
362+   template : '' 
363+ } ) 
364+ class  TestAppWithInitialValue  { 
365+   choice : number  =  1 ; 
366+ } 
0 commit comments