@@ -2497,8 +2497,9 @@ describe('MatSelect', () => {
24972497
24982498 it ( 'should be able to programmatically select a falsy option' , fakeAsync ( ( ) => {
24992499 const fixture = TestBed . createComponent ( FalsyValueSelect ) ;
2500-
25012500 fixture . detectChanges ( ) ;
2501+ flush ( ) ;
2502+
25022503 fixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement . click ( ) ;
25032504 fixture . componentInstance . control . setValue ( 0 ) ;
25042505 fixture . detectChanges ( ) ;
@@ -3049,6 +3050,8 @@ describe('MatSelect', () => {
30493050
30503051 let groupFixture = TestBed . createComponent ( SelectWithGroups ) ;
30513052 groupFixture . detectChanges ( ) ;
3053+ flush ( ) ;
3054+
30523055 trigger = groupFixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement ;
30533056 formField = groupFixture . debugElement . query ( By . css ( 'mat-form-field' ) ) . nativeElement ;
30543057
@@ -3715,7 +3718,10 @@ describe('MatSelect', () => {
37153718 } ) ;
37163719
37173720 describe ( 'with multiple selection' , ( ) => {
3718- beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [ MultiSelect ] ) ) ) ;
3721+ beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [
3722+ MultiSelect ,
3723+ MultiSelectWithLotsOfPreselectedOptions
3724+ ] ) ) ) ;
37193725
37203726 let fixture : ComponentFixture < MultiSelect > ;
37213727 let testInstance : MultiSelect ;
@@ -4096,6 +4102,17 @@ describe('MatSelect', () => {
40964102 expect ( testInstance . control . value ) . toEqual ( [ ] ) ;
40974103 } ) ;
40984104
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+
40994116 } ) ;
41004117} ) ;
41014118
@@ -4851,3 +4868,18 @@ class SelectWithoutOptionCentering {
48514868class SelectWithFormFieldLabel {
48524869 placeholder : string ;
48534870}
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