@@ -219,6 +219,34 @@ describe('MatSelectionList', () => {
219
219
} ) ;
220
220
} ) ;
221
221
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
+
222
250
describe ( 'with single option' , ( ) => {
223
251
let fixture : ComponentFixture < SelectionListWithOnlyOneOption > ;
224
252
let listOption : DebugElement ;
@@ -456,6 +484,13 @@ class SelectionListWithDisabledOption {
456
484
disableItem : boolean = false ;
457
485
}
458
486
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
+
459
494
@Component ( { template : `
460
495
<mat-selection-list id = "selection-list-4">
461
496
<mat-list-option checkboxPosition = "after" class="test-focus" id="123">
0 commit comments