@@ -2492,8 +2492,9 @@ describe('MatSelect', () => {
24922492
24932493 it ( 'should be able to programmatically select a falsy option' , fakeAsync ( ( ) => {
24942494 const fixture = TestBed . createComponent ( FalsyValueSelect ) ;
2495-
24962495 fixture . detectChanges ( ) ;
2496+ flush ( ) ;
2497+
24972498 fixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement . click ( ) ;
24982499 fixture . componentInstance . control . setValue ( 0 ) ;
24992500 fixture . detectChanges ( ) ;
@@ -3044,6 +3045,8 @@ describe('MatSelect', () => {
30443045
30453046 let groupFixture = TestBed . createComponent ( SelectWithGroups ) ;
30463047 groupFixture . detectChanges ( ) ;
3048+ flush ( ) ;
3049+
30473050 trigger = groupFixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement ;
30483051 formField = groupFixture . debugElement . query ( By . css ( 'mat-form-field' ) ) . nativeElement ;
30493052
@@ -3710,7 +3713,10 @@ describe('MatSelect', () => {
37103713 } ) ;
37113714
37123715 describe ( 'with multiple selection' , ( ) => {
3713- beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [ MultiSelect ] ) ) ) ;
3716+ beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [
3717+ MultiSelect ,
3718+ MultiSelectWithLotsOfPreselectedOptions
3719+ ] ) ) ) ;
37143720
37153721 let fixture : ComponentFixture < MultiSelect > ;
37163722 let testInstance : MultiSelect ;
@@ -4091,6 +4097,17 @@ describe('MatSelect', () => {
40914097 expect ( testInstance . control . value ) . toEqual ( [ ] ) ;
40924098 } ) ;
40934099
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+
40944111 } ) ;
40954112} ) ;
40964113
@@ -4846,3 +4863,18 @@ class SelectWithoutOptionCentering {
48464863class SelectWithFormFieldLabel {
48474864 placeholder : string ;
48484865}
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