@@ -2479,8 +2479,9 @@ describe('MatSelect', () => {
24792479
24802480 it ( 'should be able to programmatically select a falsy option' , fakeAsync ( ( ) => {
24812481 const fixture = TestBed . createComponent ( FalsyValueSelect ) ;
2482-
24832482 fixture . detectChanges ( ) ;
2483+ flush ( ) ;
2484+
24842485 fixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement . click ( ) ;
24852486 fixture . componentInstance . control . setValue ( 0 ) ;
24862487 fixture . detectChanges ( ) ;
@@ -3031,6 +3032,8 @@ describe('MatSelect', () => {
30313032
30323033 let groupFixture = TestBed . createComponent ( SelectWithGroups ) ;
30333034 groupFixture . detectChanges ( ) ;
3035+ flush ( ) ;
3036+
30343037 trigger = groupFixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement ;
30353038 formField = groupFixture . debugElement . query ( By . css ( 'mat-form-field' ) ) . nativeElement ;
30363039
@@ -3697,7 +3700,10 @@ describe('MatSelect', () => {
36973700 } ) ;
36983701
36993702 describe ( 'with multiple selection' , ( ) => {
3700- beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [ MultiSelect ] ) ) ) ;
3703+ beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [
3704+ MultiSelect ,
3705+ MultiSelectWithLotsOfPreselectedOptions
3706+ ] ) ) ) ;
37013707
37023708 let fixture : ComponentFixture < MultiSelect > ;
37033709 let testInstance : MultiSelect ;
@@ -4051,6 +4057,17 @@ describe('MatSelect', () => {
40514057 expect ( testInstance . control . value ) . toEqual ( [ ] ) ;
40524058 } ) ;
40534059
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+
40544071 } ) ;
40554072} ) ;
40564073
@@ -4806,3 +4823,18 @@ class SelectWithoutOptionCentering {
48064823class SelectWithFormFieldLabel {
48074824 placeholder : string ;
48084825}
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