@@ -195,7 +195,7 @@ describe('MdRadio', () => {
195
195
expect ( radioInstances [ 1 ] . checked ) . toBe ( true ) ;
196
196
} ) ;
197
197
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' , ( ) => {
199
199
radioInstances [ 0 ] . checked = true ;
200
200
201
201
expect ( groupInstance . value ) . toBeTruthy ( ) ;
@@ -206,6 +206,56 @@ describe('MdRadio', () => {
206
206
} ) ;
207
207
} ) ;
208
208
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
+
209
259
describe ( 'group with ngModel' , ( ) => {
210
260
let fixture : ComponentFixture < RadioGroupWithNgModel > ;
211
261
let groupDebugElement : DebugElement ;
@@ -448,6 +498,27 @@ class RadioGroupWithNgModel {
448
498
lastEvent : MdRadioChange ;
449
499
}
450
500
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
+
451
522
// TODO(jelbourn): remove eveything below when Angular supports faking events.
452
523
453
524
/**
0 commit comments