@@ -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 =
@@ -27,14 +27,25 @@ describe('MatOption component', () => {
27
27
subscription . unsubscribe ( ) ;
28
28
} ) ;
29
29
30
+ it ( 'should be able to set a custom id' , ( ) => {
31
+ const fixture = TestBed . createComponent ( BasicOption ) ;
32
+
33
+ fixture . componentInstance . id = 'custom-option' ;
34
+ fixture . detectChanges ( ) ;
35
+
36
+ const optionInstance = fixture . debugElement . query ( By . directive ( MatOption ) ) . componentInstance ;
37
+
38
+ expect ( optionInstance . id ) . toBe ( 'custom-option' ) ;
39
+ } ) ;
40
+
30
41
describe ( 'ripples' , ( ) => {
31
- let fixture : ComponentFixture < OptionWithDisable > ;
42
+ let fixture : ComponentFixture < BasicOption > ;
32
43
let optionDebugElement : DebugElement ;
33
44
let optionNativeElement : HTMLElement ;
34
45
let optionInstance : MatOption ;
35
46
36
47
beforeEach ( ( ) => {
37
- fixture = TestBed . createComponent ( OptionWithDisable ) ;
48
+ fixture = TestBed . createComponent ( BasicOption ) ;
38
49
fixture . detectChanges ( ) ;
39
50
40
51
optionDebugElement = fixture . debugElement . query ( By . directive ( MatOption ) ) ;
@@ -73,8 +84,9 @@ describe('MatOption component', () => {
73
84
} ) ;
74
85
75
86
@Component ( {
76
- template : `<mat-option [disabled]="disabled"></mat-option>`
87
+ template : `<mat-option [id]="id" [ disabled]="disabled"></mat-option>`
77
88
} )
78
- class OptionWithDisable {
89
+ class BasicOption {
79
90
disabled : boolean ;
91
+ id : string ;
80
92
}
0 commit comments