@@ -214,6 +214,34 @@ describe('MdSelectionList', () => {
214
214
} ) ;
215
215
} ) ;
216
216
217
+ describe ( 'with list option selected' , ( ) => {
218
+ let fixture : ComponentFixture < SelectionListWithListOptions > ;
219
+ let listItemEl : DebugElement ;
220
+ let selectionList : DebugElement ;
221
+
222
+ beforeEach ( async ( ( ) => {
223
+ TestBed . configureTestingModule ( {
224
+ imports : [ MdListModule ] ,
225
+ declarations : [ SelectionListWithSelecedOption ] ,
226
+ } ) ;
227
+
228
+ TestBed . compileComponents ( ) ;
229
+ } ) ) ;
230
+
231
+ beforeEach ( async ( ( ) => {
232
+ fixture = TestBed . createComponent ( SelectionListWithSelecedOption ) ;
233
+ listItemEl = fixture . debugElement . query ( By . directive ( MdListOption ) ) ;
234
+ selectionList = fixture . debugElement . query ( By . directive ( MdSelectionList ) ) ;
235
+ fixture . detectChanges ( ) ;
236
+ } ) ) ;
237
+
238
+ it ( 'should set its initial selected state in the selectedOptions' , ( ) => {
239
+ let optionEl = listItemEl . injector . get ( MdListOption ) ;
240
+ let selectedOptions = selectionList . componentInstance . selectedOptions ;
241
+ expect ( selectedOptions . isSelected ( optionEl ) ) . toBeTruthy ( ) ;
242
+ } ) ;
243
+ } ) ;
244
+
217
245
describe ( 'with single option' , ( ) => {
218
246
let fixture : ComponentFixture < SelectionListWithOnlyOneOption > ;
219
247
let listOption : DebugElement ;
@@ -450,6 +478,13 @@ class SelectionListWithDisabledOption {
450
478
disableItem : boolean = false ;
451
479
}
452
480
481
+ @Component ( { template : `
482
+ <mat-selection-list>
483
+ <md-list-option [selected]="true">Item</md-list-option>
484
+ </mat-selection-list>` } )
485
+ class SelectionListWithSelecedOption {
486
+ }
487
+
453
488
@Component ( { template : `
454
489
<mat-selection-list id = "selection-list-4">
455
490
<md-list-option checkboxPosition = "after" class="test-focus" id="123">
0 commit comments