@@ -9,12 +9,12 @@ describe('MatOption component', () => {
99 beforeEach ( async ( ( ) => {
1010 TestBed . configureTestingModule ( {
1111 imports : [ MatOptionModule ] ,
12- declarations : [ OptionWithDisable ]
12+ declarations : [ BasicOption ]
1313 } ) . compileComponents ( ) ;
1414 } ) ) ;
1515
1616 it ( 'should complete the `stateChanges` stream on destroy' , ( ) => {
17- const fixture = TestBed . createComponent ( OptionWithDisable ) ;
17+ const fixture = TestBed . createComponent ( BasicOption ) ;
1818 fixture . detectChanges ( ) ;
1919
2020 const optionInstance : MatOption =
@@ -28,7 +28,7 @@ describe('MatOption component', () => {
2828 } ) ;
2929
3030 it ( 'should not emit to `onSelectionChange` if selecting an already-selected option' , ( ) => {
31- const fixture = TestBed . createComponent ( OptionWithDisable ) ;
31+ const fixture = TestBed . createComponent ( BasicOption ) ;
3232 fixture . detectChanges ( ) ;
3333
3434 const optionInstance : MatOption =
@@ -50,7 +50,7 @@ describe('MatOption component', () => {
5050 } ) ;
5151
5252 it ( 'should not emit to `onSelectionChange` if deselecting an unselected option' , ( ) => {
53- const fixture = TestBed . createComponent ( OptionWithDisable ) ;
53+ const fixture = TestBed . createComponent ( BasicOption ) ;
5454 fixture . detectChanges ( ) ;
5555
5656 const optionInstance : MatOption =
@@ -71,14 +71,25 @@ describe('MatOption component', () => {
7171 subscription . unsubscribe ( ) ;
7272 } ) ;
7373
74+ it ( 'should be able to set a custom id' , ( ) => {
75+ const fixture = TestBed . createComponent ( BasicOption ) ;
76+
77+ fixture . componentInstance . id = 'custom-option' ;
78+ fixture . detectChanges ( ) ;
79+
80+ const optionInstance = fixture . debugElement . query ( By . directive ( MatOption ) ) . componentInstance ;
81+
82+ expect ( optionInstance . id ) . toBe ( 'custom-option' ) ;
83+ } ) ;
84+
7485 describe ( 'ripples' , ( ) => {
75- let fixture : ComponentFixture < OptionWithDisable > ;
86+ let fixture : ComponentFixture < BasicOption > ;
7687 let optionDebugElement : DebugElement ;
7788 let optionNativeElement : HTMLElement ;
7889 let optionInstance : MatOption ;
7990
8091 beforeEach ( ( ) => {
81- fixture = TestBed . createComponent ( OptionWithDisable ) ;
92+ fixture = TestBed . createComponent ( BasicOption ) ;
8293 fixture . detectChanges ( ) ;
8394
8495 optionDebugElement = fixture . debugElement . query ( By . directive ( MatOption ) ) ;
@@ -117,8 +128,9 @@ describe('MatOption component', () => {
117128} ) ;
118129
119130@Component ( {
120- template : `<mat-option [disabled]="disabled"></mat-option>`
131+ template : `<mat-option [id]="id" [ disabled]="disabled"></mat-option>`
121132} )
122- class OptionWithDisable {
133+ class BasicOption {
123134 disabled : boolean ;
135+ id : string ;
124136}
0 commit comments