@@ -2497,8 +2497,9 @@ describe('MatSelect', () => {
2497
2497
2498
2498
it ( 'should be able to programmatically select a falsy option' , fakeAsync ( ( ) => {
2499
2499
const fixture = TestBed . createComponent ( FalsyValueSelect ) ;
2500
-
2501
2500
fixture . detectChanges ( ) ;
2501
+ flush ( ) ;
2502
+
2502
2503
fixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement . click ( ) ;
2503
2504
fixture . componentInstance . control . setValue ( 0 ) ;
2504
2505
fixture . detectChanges ( ) ;
@@ -3049,6 +3050,8 @@ describe('MatSelect', () => {
3049
3050
3050
3051
let groupFixture = TestBed . createComponent ( SelectWithGroups ) ;
3051
3052
groupFixture . detectChanges ( ) ;
3053
+ flush ( ) ;
3054
+
3052
3055
trigger = groupFixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement ;
3053
3056
formField = groupFixture . debugElement . query ( By . css ( 'mat-form-field' ) ) . nativeElement ;
3054
3057
@@ -3715,7 +3718,10 @@ describe('MatSelect', () => {
3715
3718
} ) ;
3716
3719
3717
3720
describe ( 'with multiple selection' , ( ) => {
3718
- beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [ MultiSelect ] ) ) ) ;
3721
+ beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [
3722
+ MultiSelect ,
3723
+ MultiSelectWithLotsOfPreselectedOptions
3724
+ ] ) ) ) ;
3719
3725
3720
3726
let fixture : ComponentFixture < MultiSelect > ;
3721
3727
let testInstance : MultiSelect ;
@@ -4096,6 +4102,17 @@ describe('MatSelect', () => {
4096
4102
expect ( testInstance . control . value ) . toEqual ( [ ] ) ;
4097
4103
} ) ;
4098
4104
4105
+ it ( 'should not throw with a large amount of preselected options' , fakeAsync ( ( ) => {
4106
+ fixture . destroy ( ) ;
4107
+
4108
+ const lotsOfOptionsFixture = TestBed . createComponent ( MultiSelectWithLotsOfPreselectedOptions ) ;
4109
+
4110
+ expect ( ( ) => {
4111
+ lotsOfOptionsFixture . detectChanges ( ) ;
4112
+ flush ( ) ;
4113
+ } ) . not . toThrow ( ) ;
4114
+ } ) ) ;
4115
+
4099
4116
} ) ;
4100
4117
} ) ;
4101
4118
@@ -4851,3 +4868,18 @@ class SelectWithoutOptionCentering {
4851
4868
class SelectWithFormFieldLabel {
4852
4869
placeholder : string ;
4853
4870
}
4871
+
4872
+
4873
+ @Component ( {
4874
+ template : `
4875
+ <mat-form-field>
4876
+ <mat-select multiple [ngModel]="value">
4877
+ <mat-option *ngFor="let item of items" [value]="item">{{item}}</mat-option>
4878
+ </mat-select>
4879
+ </mat-form-field>
4880
+ `
4881
+ } )
4882
+ class MultiSelectWithLotsOfPreselectedOptions {
4883
+ items = new Array ( 1000 ) . fill ( 0 ) . map ( ( _ , i ) => i ) ;
4884
+ value = [ ...this . items ] ;
4885
+ }
0 commit comments