@@ -219,6 +219,34 @@ describe('MatSelectionList', () => {
219219 } ) ;
220220 } ) ;
221221
222+ describe ( 'with list option selected' , ( ) => {
223+ let fixture : ComponentFixture < SelectionListWithListOptions > ;
224+ let listItemEl : DebugElement ;
225+ let selectionList : DebugElement ;
226+
227+ beforeEach ( async ( ( ) => {
228+ TestBed . configureTestingModule ( {
229+ imports : [ MdListModule ] ,
230+ declarations : [ SelectionListWithSelecedOption ] ,
231+ } ) ;
232+
233+ TestBed . compileComponents ( ) ;
234+ } ) ) ;
235+
236+ beforeEach ( async ( ( ) => {
237+ fixture = TestBed . createComponent ( SelectionListWithSelecedOption ) ;
238+ listItemEl = fixture . debugElement . query ( By . directive ( MdListOption ) ) ;
239+ selectionList = fixture . debugElement . query ( By . directive ( MdSelectionList ) ) ;
240+ fixture . detectChanges ( ) ;
241+ } ) ) ;
242+
243+ it ( 'should set its initial selected state in the selectedOptions' , ( ) => {
244+ let optionEl = listItemEl . injector . get ( MdListOption ) ;
245+ let selectedOptions = selectionList . componentInstance . selectedOptions ;
246+ expect ( selectedOptions . isSelected ( optionEl ) ) . toBeTruthy ( ) ;
247+ } ) ;
248+ } ) ;
249+
222250 describe ( 'with single option' , ( ) => {
223251 let fixture : ComponentFixture < SelectionListWithOnlyOneOption > ;
224252 let listOption : DebugElement ;
@@ -456,6 +484,13 @@ class SelectionListWithDisabledOption {
456484 disableItem : boolean = false ;
457485}
458486
487+ @Component ( { template : `
488+ <mat-selection-list>
489+ <md-list-option [selected]="true">Item</md-list-option>
490+ </mat-selection-list>` } )
491+ class SelectionListWithSelecedOption {
492+ }
493+
459494@Component ( { template : `
460495 <mat-selection-list id = "selection-list-4">
461496 <mat-list-option checkboxPosition = "after" class="test-focus" id="123">
0 commit comments