@@ -2479,8 +2479,9 @@ describe('MatSelect', () => {
2479
2479
2480
2480
it ( 'should be able to programmatically select a falsy option' , fakeAsync ( ( ) => {
2481
2481
const fixture = TestBed . createComponent ( FalsyValueSelect ) ;
2482
-
2483
2482
fixture . detectChanges ( ) ;
2483
+ flush ( ) ;
2484
+
2484
2485
fixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement . click ( ) ;
2485
2486
fixture . componentInstance . control . setValue ( 0 ) ;
2486
2487
fixture . detectChanges ( ) ;
@@ -3031,6 +3032,8 @@ describe('MatSelect', () => {
3031
3032
3032
3033
let groupFixture = TestBed . createComponent ( SelectWithGroups ) ;
3033
3034
groupFixture . detectChanges ( ) ;
3035
+ flush ( ) ;
3036
+
3034
3037
trigger = groupFixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement ;
3035
3038
formField = groupFixture . debugElement . query ( By . css ( 'mat-form-field' ) ) . nativeElement ;
3036
3039
@@ -3697,7 +3700,10 @@ describe('MatSelect', () => {
3697
3700
} ) ;
3698
3701
3699
3702
describe ( 'with multiple selection' , ( ) => {
3700
- beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [ MultiSelect ] ) ) ) ;
3703
+ beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [
3704
+ MultiSelect ,
3705
+ MultiSelectWithLotsOfPreselectedOptions
3706
+ ] ) ) ) ;
3701
3707
3702
3708
let fixture : ComponentFixture < MultiSelect > ;
3703
3709
let testInstance : MultiSelect ;
@@ -4051,6 +4057,17 @@ describe('MatSelect', () => {
4051
4057
expect ( testInstance . control . value ) . toEqual ( [ ] ) ;
4052
4058
} ) ;
4053
4059
4060
+ it ( 'should not throw with a large amount of preselected options' , fakeAsync ( ( ) => {
4061
+ fixture . destroy ( ) ;
4062
+
4063
+ const lotsOfOptionsFixture = TestBed . createComponent ( MultiSelectWithLotsOfPreselectedOptions ) ;
4064
+
4065
+ expect ( ( ) => {
4066
+ lotsOfOptionsFixture . detectChanges ( ) ;
4067
+ flush ( ) ;
4068
+ } ) . not . toThrow ( ) ;
4069
+ } ) ) ;
4070
+
4054
4071
} ) ;
4055
4072
} ) ;
4056
4073
@@ -4806,3 +4823,18 @@ class SelectWithoutOptionCentering {
4806
4823
class SelectWithFormFieldLabel {
4807
4824
placeholder : string ;
4808
4825
}
4826
+
4827
+
4828
+ @Component ( {
4829
+ template : `
4830
+ <mat-form-field>
4831
+ <mat-select multiple [ngModel]="value">
4832
+ <mat-option *ngFor="let item of items" [value]="item">{{item}}</mat-option>
4833
+ </mat-select>
4834
+ </mat-form-field>
4835
+ `
4836
+ } )
4837
+ class MultiSelectWithLotsOfPreselectedOptions {
4838
+ items = new Array ( 1000 ) . fill ( 0 ) . map ( ( _ , i ) => i ) ;
4839
+ value = [ ...this . items ] ;
4840
+ }
0 commit comments