@@ -2492,8 +2492,9 @@ describe('MatSelect', () => {
2492
2492
2493
2493
it ( 'should be able to programmatically select a falsy option' , fakeAsync ( ( ) => {
2494
2494
const fixture = TestBed . createComponent ( FalsyValueSelect ) ;
2495
-
2496
2495
fixture . detectChanges ( ) ;
2496
+ flush ( ) ;
2497
+
2497
2498
fixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement . click ( ) ;
2498
2499
fixture . componentInstance . control . setValue ( 0 ) ;
2499
2500
fixture . detectChanges ( ) ;
@@ -3044,6 +3045,8 @@ describe('MatSelect', () => {
3044
3045
3045
3046
let groupFixture = TestBed . createComponent ( SelectWithGroups ) ;
3046
3047
groupFixture . detectChanges ( ) ;
3048
+ flush ( ) ;
3049
+
3047
3050
trigger = groupFixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement ;
3048
3051
formField = groupFixture . debugElement . query ( By . css ( 'mat-form-field' ) ) . nativeElement ;
3049
3052
@@ -3710,7 +3713,10 @@ describe('MatSelect', () => {
3710
3713
} ) ;
3711
3714
3712
3715
describe ( 'with multiple selection' , ( ) => {
3713
- beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [ MultiSelect ] ) ) ) ;
3716
+ beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [
3717
+ MultiSelect ,
3718
+ MultiSelectWithLotsOfPreselectedOptions
3719
+ ] ) ) ) ;
3714
3720
3715
3721
let fixture : ComponentFixture < MultiSelect > ;
3716
3722
let testInstance : MultiSelect ;
@@ -4091,6 +4097,17 @@ describe('MatSelect', () => {
4091
4097
expect ( testInstance . control . value ) . toEqual ( [ ] ) ;
4092
4098
} ) ;
4093
4099
4100
+ it ( 'should not throw with a large amount of preselected options' , fakeAsync ( ( ) => {
4101
+ fixture . destroy ( ) ;
4102
+
4103
+ const lotsOfOptionsFixture = TestBed . createComponent ( MultiSelectWithLotsOfPreselectedOptions ) ;
4104
+
4105
+ expect ( ( ) => {
4106
+ lotsOfOptionsFixture . detectChanges ( ) ;
4107
+ flush ( ) ;
4108
+ } ) . not . toThrow ( ) ;
4109
+ } ) ) ;
4110
+
4094
4111
} ) ;
4095
4112
} ) ;
4096
4113
@@ -4846,3 +4863,18 @@ class SelectWithoutOptionCentering {
4846
4863
class SelectWithFormFieldLabel {
4847
4864
placeholder : string ;
4848
4865
}
4866
+
4867
+
4868
+ @Component ( {
4869
+ template : `
4870
+ <mat-form-field>
4871
+ <mat-select multiple [ngModel]="value">
4872
+ <mat-option *ngFor="let item of items" [value]="item">{{item}}</mat-option>
4873
+ </mat-select>
4874
+ </mat-form-field>
4875
+ `
4876
+ } )
4877
+ class MultiSelectWithLotsOfPreselectedOptions {
4878
+ items = new Array ( 1000 ) . fill ( 0 ) . map ( ( _ , i ) => i ) ;
4879
+ value = [ ...this . items ] ;
4880
+ }
0 commit comments