@@ -9,12 +9,12 @@ describe('MatOption component', () => {
9
9
beforeEach ( async ( ( ) => {
10
10
TestBed . configureTestingModule ( {
11
11
imports : [ MatOptionModule ] ,
12
- declarations : [ OptionWithDisable ]
12
+ declarations : [ BasicOption ]
13
13
} ) . compileComponents ( ) ;
14
14
} ) ) ;
15
15
16
16
it ( 'should complete the `stateChanges` stream on destroy' , ( ) => {
17
- const fixture = TestBed . createComponent ( OptionWithDisable ) ;
17
+ const fixture = TestBed . createComponent ( BasicOption ) ;
18
18
fixture . detectChanges ( ) ;
19
19
20
20
const optionInstance : MatOption =
@@ -28,7 +28,7 @@ describe('MatOption component', () => {
28
28
} ) ;
29
29
30
30
it ( 'should not emit to `onSelectionChange` if selecting an already-selected option' , ( ) => {
31
- const fixture = TestBed . createComponent ( OptionWithDisable ) ;
31
+ const fixture = TestBed . createComponent ( BasicOption ) ;
32
32
fixture . detectChanges ( ) ;
33
33
34
34
const optionInstance : MatOption =
@@ -50,7 +50,7 @@ describe('MatOption component', () => {
50
50
} ) ;
51
51
52
52
it ( 'should not emit to `onSelectionChange` if deselecting an unselected option' , ( ) => {
53
- const fixture = TestBed . createComponent ( OptionWithDisable ) ;
53
+ const fixture = TestBed . createComponent ( BasicOption ) ;
54
54
fixture . detectChanges ( ) ;
55
55
56
56
const optionInstance : MatOption =
@@ -71,14 +71,25 @@ describe('MatOption component', () => {
71
71
subscription . unsubscribe ( ) ;
72
72
} ) ;
73
73
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
+
74
85
describe ( 'ripples' , ( ) => {
75
- let fixture : ComponentFixture < OptionWithDisable > ;
86
+ let fixture : ComponentFixture < BasicOption > ;
76
87
let optionDebugElement : DebugElement ;
77
88
let optionNativeElement : HTMLElement ;
78
89
let optionInstance : MatOption ;
79
90
80
91
beforeEach ( ( ) => {
81
- fixture = TestBed . createComponent ( OptionWithDisable ) ;
92
+ fixture = TestBed . createComponent ( BasicOption ) ;
82
93
fixture . detectChanges ( ) ;
83
94
84
95
optionDebugElement = fixture . debugElement . query ( By . directive ( MatOption ) ) ;
@@ -117,8 +128,9 @@ describe('MatOption component', () => {
117
128
} ) ;
118
129
119
130
@Component ( {
120
- template : `<mat-option [disabled]="disabled"></mat-option>`
131
+ template : `<mat-option [id]="id" [ disabled]="disabled"></mat-option>`
121
132
} )
122
- class OptionWithDisable {
133
+ class BasicOption {
123
134
disabled : boolean ;
135
+ id : string ;
124
136
}
0 commit comments