@@ -191,27 +191,23 @@ describe('MatSelect', () => {
191
191
fixture . detectChanges ( ) ;
192
192
193
193
const labelId = fixture . nativeElement . querySelector ( '.mat-form-field-label' ) . id ;
194
- const valueId = fixture . nativeElement . querySelector ( '.mat-select-value' ) . id ;
195
194
196
- expect ( select . getAttribute ( 'aria-labelledby' ) ) . toBe ( `${ labelId } ${ valueId } myLabelId` ) ;
195
+ expect ( select . getAttribute ( 'aria-labelledby' ) ) . toBe ( `${ labelId } myLabelId` ) ;
197
196
} ) ) ;
198
197
199
- it ( 'should set aria-labelledby to the value and label IDs' , fakeAsync ( ( ) => {
198
+ it ( 'should set aria-labelledby to the label IDs' , fakeAsync ( ( ) => {
200
199
fixture . detectChanges ( ) ;
201
200
202
201
const labelId = fixture . nativeElement . querySelector ( '.mat-form-field-label' ) . id ;
203
- const valueId = fixture . nativeElement . querySelector ( '.mat-select-value' ) . id ;
204
- expect ( select . getAttribute ( 'aria-labelledby' ) ) . toBe ( `${ labelId } ${ valueId } ` ) ;
202
+ expect ( select . getAttribute ( 'aria-labelledby' ) ) . toBe ( `${ labelId } ` ) ;
205
203
} ) ) ;
206
204
207
- it ( 'should trim the trigger aria-labelledby when there is no label' , fakeAsync ( ( ) => {
205
+ it ( 'should remove the aria-labelledby when there is no label' , fakeAsync ( ( ) => {
208
206
// Reset the `placeholder` which also controls the label of the form field.
209
207
fixture . componentInstance . select . placeholder = '' ;
210
208
fixture . detectChanges ( ) ;
211
209
212
- // Note that we assert that there are no spaces around the value.
213
- const valueId = fixture . nativeElement . querySelector ( '.mat-select-value' ) . id ;
214
- expect ( select . getAttribute ( 'aria-labelledby' ) ) . toBe ( `${ valueId } ` ) ;
210
+ expect ( select . hasAttribute ( 'aria-labelledby' ) ) . toBeFalse ( ) ;
215
211
} ) ) ;
216
212
217
213
it ( 'should set the tabindex of the select to 0 by default' , fakeAsync ( ( ) => {
@@ -285,15 +281,14 @@ describe('MatSelect', () => {
285
281
expect ( select . getAttribute ( 'tabindex' ) ) . toEqual ( '0' ) ;
286
282
} ) ) ;
287
283
288
- it ( 'should set `aria-labelledby` to the value ID if there is no form field' , ( ) => {
284
+ it ( 'should remove `aria-labelledby` if there is no form field' , ( ) => {
289
285
fixture . destroy ( ) ;
290
286
291
287
const labelFixture = TestBed . createComponent ( SelectWithChangeEvent ) ;
292
288
labelFixture . detectChanges ( ) ;
293
289
select = labelFixture . debugElement . query ( By . css ( 'mat-select' ) ) ! . nativeElement ;
294
- const valueId = labelFixture . nativeElement . querySelector ( '.mat-select-value' ) . id ;
295
290
296
- expect ( select . getAttribute ( 'aria-labelledby' ) ?. trim ( ) ) . toBe ( valueId ) ;
291
+ expect ( select . hasAttribute ( 'aria-labelledby' ) ) . toBeFalse ( ) ;
297
292
} ) ;
298
293
299
294
it ( 'should select options via the UP/DOWN arrow keys on a closed select' , fakeAsync ( ( ) => {
0 commit comments