@@ -195,7 +195,7 @@ describe('MdRadio', () => {
195195 expect ( radioInstances [ 1 ] . checked ) . toBe ( true ) ;
196196 } ) ;
197197
198- it ( 'should deselect all of the checkboxes when the group value is cleared' , ( ) => {
198+ it ( 'should deselect all of the radioButtones when the group value is cleared' , ( ) => {
199199 radioInstances [ 0 ] . checked = true ;
200200
201201 expect ( groupInstance . value ) . toBeTruthy ( ) ;
@@ -206,6 +206,56 @@ describe('MdRadio', () => {
206206 } ) ;
207207 } ) ;
208208
209+ describe ( 'with provided aria-label ' , ( ) => {
210+ let fixture : ComponentFixture < any > ;
211+ let radioButtonDebugElement : DebugElement ;
212+ let radioButtonNativeElement : HTMLElement ;
213+ let inputElement : HTMLInputElement ;
214+
215+ it ( 'should use the provided aria-label' , async ( ( ) => {
216+ builder . createAsync ( RadioButtonWithAriaLabel ) . then ( f => {
217+ fixture = f ;
218+ radioButtonDebugElement = fixture . debugElement . query ( By . directive ( MdRadioButton ) ) ;
219+ radioButtonNativeElement = radioButtonDebugElement . nativeElement ;
220+ inputElement = < HTMLInputElement > radioButtonNativeElement . querySelector ( 'input' ) ;
221+
222+ fixture . detectChanges ( ) ;
223+ expect ( inputElement . getAttribute ( 'aria-label' ) ) . toBe ( 'superRadio' ) ;
224+ } ) ;
225+ } ) ) ;
226+ } ) ;
227+
228+ describe ( 'with provided aria-labelledby ' , ( ) => {
229+ let fixture : ComponentFixture < any > ;
230+ let radioButtonDebugElement : DebugElement ;
231+ let radioButtonNativeElement : HTMLElement ;
232+ let inputElement : HTMLInputElement ;
233+
234+ it ( 'should use the provided aria-labelledby' , async ( ( ) => {
235+ builder . createAsync ( RadioButtonWithAriaLabelledby ) . then ( f => {
236+ fixture = f ;
237+ radioButtonDebugElement = fixture . debugElement . query ( By . directive ( MdRadioButton ) ) ;
238+ radioButtonNativeElement = radioButtonDebugElement . nativeElement ;
239+ inputElement = < HTMLInputElement > radioButtonNativeElement . querySelector ( 'input' ) ;
240+
241+ fixture . detectChanges ( ) ;
242+ expect ( inputElement . getAttribute ( 'aria-labelledby' ) ) . toBe ( 'superByRadio' ) ;
243+ } ) ;
244+ } ) ) ;
245+
246+ it ( 'should not assign aria-labelledby if none is provided' , async ( ( ) => {
247+ builder . createAsync ( SingleRadioButton ) . then ( f => {
248+ fixture = f ;
249+ radioButtonDebugElement = fixture . debugElement . query ( By . directive ( MdRadioButton ) ) ;
250+ radioButtonNativeElement = radioButtonDebugElement . nativeElement ;
251+ inputElement = < HTMLInputElement > radioButtonNativeElement . querySelector ( 'input' ) ;
252+
253+ fixture . detectChanges ( ) ;
254+ expect ( inputElement . getAttribute ( 'aria-labelledby' ) ) . toBe ( null ) ;
255+ } ) ;
256+ } ) ) ;
257+ } ) ;
258+
209259 describe ( 'group with ngModel' , ( ) => {
210260 let fixture : ComponentFixture < RadioGroupWithNgModel > ;
211261 let groupDebugElement : DebugElement ;
@@ -448,6 +498,27 @@ class RadioGroupWithNgModel {
448498 lastEvent : MdRadioChange ;
449499}
450500
501+ /** Simple test component with an aria-label set. */
502+ @Component ( {
503+ directives : [ MdRadioButton ] ,
504+ template : `<md-radio-button name="season" value="spring" aria-label="superRadio">Spring</md-radio-button>`
505+ } )
506+ class RadioButtonWithAriaLabel { }
507+
508+ /** Simple test component with an aria-label set. */
509+ @Component ( {
510+ directives : [ MdRadioButton ] ,
511+ template : `<md-radio-button name="season" value="spring" aria-labelledby="superByRadio">Spring</md-radio-button>`
512+ } )
513+ class RadioButtonWithAriaLabelledby { }
514+
515+ /** Simple test component with an aria-label set. */
516+ @Component ( {
517+ directives : [ MdRadioButton ] ,
518+ template : `<md-radio-button name="season" value="spring" >Spring</md-radio-button>`
519+ } )
520+ class SingleRadioButton { }
521+
451522// TODO(jelbourn): remove eveything below when Angular supports faking events.
452523
453524/**
0 commit comments