@@ -328,6 +328,41 @@ describe('MdSelect', () => {
328328 expect ( optionInstances [ 2 ] . selected ) . toBe ( false ) ;
329329 } ) ;
330330
331+ it ( 'should deselect other options when one is programmatically selected' , ( ) => {
332+ let control = fixture . componentInstance . control ;
333+ let foods = fixture . componentInstance . foods ;
334+
335+ trigger . click ( ) ;
336+ fixture . detectChanges ( ) ;
337+
338+ let options =
339+ overlayContainerElement . querySelectorAll ( 'md-option' ) as NodeListOf < HTMLElement > ;
340+
341+ options [ 0 ] . click ( ) ;
342+ fixture . detectChanges ( ) ;
343+
344+ control . setValue ( foods [ 1 ] . value ) ;
345+ fixture . detectChanges ( ) ;
346+
347+ trigger . click ( ) ;
348+ fixture . detectChanges ( ) ;
349+
350+ options =
351+ overlayContainerElement . querySelectorAll ( 'md-option' ) as NodeListOf < HTMLElement > ;
352+
353+ expect ( options [ 0 ] . classList )
354+ . not . toContain ( 'mat-selected' , 'Expected first option to no longer be selected' ) ;
355+ expect ( options [ 1 ] . classList )
356+ . toContain ( 'mat-selected' , 'Expected second option to be selected' ) ;
357+
358+ const optionInstances = fixture . componentInstance . options . toArray ( ) ;
359+
360+ expect ( optionInstances [ 0 ] . selected )
361+ . toBe ( false , 'Expected first option to no longer be selected' ) ;
362+ expect ( optionInstances [ 1 ] . selected )
363+ . toBe ( true , 'Expected second option to be selected' ) ;
364+ } ) ;
365+
331366 it ( 'should remove selection if option has been removed' , async ( ( ) => {
332367 let select = fixture . componentInstance . select ;
333368
0 commit comments