@@ -2664,8 +2664,9 @@ describe('MatSelect', () => {
2664
2664
2665
2665
it ( 'should be able to programmatically select a falsy option' , fakeAsync ( ( ) => {
2666
2666
const fixture = TestBed . createComponent ( FalsyValueSelect ) ;
2667
-
2668
2667
fixture . detectChanges ( ) ;
2668
+ flush ( ) ;
2669
+
2669
2670
fixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement . click ( ) ;
2670
2671
fixture . componentInstance . control . setValue ( 0 ) ;
2671
2672
fixture . detectChanges ( ) ;
@@ -3216,6 +3217,8 @@ describe('MatSelect', () => {
3216
3217
3217
3218
let groupFixture = TestBed . createComponent ( SelectWithGroups ) ;
3218
3219
groupFixture . detectChanges ( ) ;
3220
+ flush ( ) ;
3221
+
3219
3222
trigger = groupFixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement ;
3220
3223
formField = groupFixture . debugElement . query ( By . css ( 'mat-form-field' ) ) . nativeElement ;
3221
3224
@@ -3883,7 +3886,10 @@ describe('MatSelect', () => {
3883
3886
} ) ;
3884
3887
3885
3888
describe ( 'with multiple selection' , ( ) => {
3886
- beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [ MultiSelect ] ) ) ) ;
3889
+ beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [
3890
+ MultiSelect ,
3891
+ MultiSelectWithLotsOfPreselectedOptions
3892
+ ] ) ) ) ;
3887
3893
3888
3894
let fixture : ComponentFixture < MultiSelect > ;
3889
3895
let testInstance : MultiSelect ;
@@ -4264,6 +4270,17 @@ describe('MatSelect', () => {
4264
4270
expect ( testInstance . control . value ) . toEqual ( [ ] ) ;
4265
4271
} ) ;
4266
4272
4273
+ it ( 'should not throw with a large amount of preselected options' , fakeAsync ( ( ) => {
4274
+ fixture . destroy ( ) ;
4275
+
4276
+ const lotsOfOptionsFixture = TestBed . createComponent ( MultiSelectWithLotsOfPreselectedOptions ) ;
4277
+
4278
+ expect ( ( ) => {
4279
+ lotsOfOptionsFixture . detectChanges ( ) ;
4280
+ flush ( ) ;
4281
+ } ) . not . toThrow ( ) ;
4282
+ } ) ) ;
4283
+
4267
4284
} ) ;
4268
4285
} ) ;
4269
4286
@@ -5038,3 +5055,17 @@ class SelectWithFormFieldLabel {
5038
5055
class SelectWithNgIfAndLabel {
5039
5056
showSelect = true ;
5040
5057
}
5058
+
5059
+ @Component ( {
5060
+ template : `
5061
+ <mat-form-field>
5062
+ <mat-select multiple [ngModel]="value">
5063
+ <mat-option *ngFor="let item of items" [value]="item">{{item}}</mat-option>
5064
+ </mat-select>
5065
+ </mat-form-field>
5066
+ `
5067
+ } )
5068
+ class MultiSelectWithLotsOfPreselectedOptions {
5069
+ items = new Array ( 1000 ) . fill ( 0 ) . map ( ( _ , i ) => i ) ;
5070
+ value = [ ...this . items ] ;
5071
+ }
0 commit comments