@@ -2686,8 +2686,9 @@ describe('MatSelect', () => {
2686
2686
2687
2687
it ( 'should be able to programmatically select a falsy option' , fakeAsync ( ( ) => {
2688
2688
const fixture = TestBed . createComponent ( FalsyValueSelect ) ;
2689
-
2690
2689
fixture . detectChanges ( ) ;
2690
+ flush ( ) ;
2691
+
2691
2692
fixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) ! . nativeElement . click ( ) ;
2692
2693
fixture . componentInstance . control . setValue ( 0 ) ;
2693
2694
fixture . detectChanges ( ) ;
@@ -3238,6 +3239,8 @@ describe('MatSelect', () => {
3238
3239
3239
3240
let groupFixture = TestBed . createComponent ( SelectWithGroups ) ;
3240
3241
groupFixture . detectChanges ( ) ;
3242
+ flush ( ) ;
3243
+
3241
3244
trigger = groupFixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) ! . nativeElement ;
3242
3245
formField = groupFixture . debugElement . query ( By . css ( 'mat-form-field' ) ) ! . nativeElement ;
3243
3246
@@ -3905,7 +3908,10 @@ describe('MatSelect', () => {
3905
3908
} ) ;
3906
3909
3907
3910
describe ( 'with multiple selection' , ( ) => {
3908
- beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [ MultiSelect ] ) ) ) ;
3911
+ beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [
3912
+ MultiSelect ,
3913
+ MultiSelectWithLotsOfPreselectedOptions
3914
+ ] ) ) ) ;
3909
3915
3910
3916
let fixture : ComponentFixture < MultiSelect > ;
3911
3917
let testInstance : MultiSelect ;
@@ -4286,6 +4292,17 @@ describe('MatSelect', () => {
4286
4292
expect ( testInstance . control . value ) . toEqual ( [ ] ) ;
4287
4293
} ) ;
4288
4294
4295
+ it ( 'should not throw with a large amount of preselected options' , fakeAsync ( ( ) => {
4296
+ fixture . destroy ( ) ;
4297
+
4298
+ const lotsOfOptionsFixture = TestBed . createComponent ( MultiSelectWithLotsOfPreselectedOptions ) ;
4299
+
4300
+ expect ( ( ) => {
4301
+ lotsOfOptionsFixture . detectChanges ( ) ;
4302
+ flush ( ) ;
4303
+ } ) . not . toThrow ( ) ;
4304
+ } ) ) ;
4305
+
4289
4306
} ) ;
4290
4307
} ) ;
4291
4308
@@ -5062,3 +5079,17 @@ class SelectWithFormFieldLabel {
5062
5079
class SelectWithNgIfAndLabel {
5063
5080
showSelect = true ;
5064
5081
}
5082
+
5083
+ @Component ( {
5084
+ template : `
5085
+ <mat-form-field>
5086
+ <mat-select multiple [ngModel]="value">
5087
+ <mat-option *ngFor="let item of items" [value]="item">{{item}}</mat-option>
5088
+ </mat-select>
5089
+ </mat-form-field>
5090
+ `
5091
+ } )
5092
+ class MultiSelectWithLotsOfPreselectedOptions {
5093
+ items = new Array ( 1000 ) . fill ( 0 ) . map ( ( _ , i ) => i ) ;
5094
+ value = [ ...this . items ] ;
5095
+ }
0 commit comments