@@ -2686,8 +2686,9 @@ describe('MatSelect', () => {
26862686
26872687 it ( 'should be able to programmatically select a falsy option' , fakeAsync ( ( ) => {
26882688 const fixture = TestBed . createComponent ( FalsyValueSelect ) ;
2689-
26902689 fixture . detectChanges ( ) ;
2690+ flush ( ) ;
2691+
26912692 fixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) ! . nativeElement . click ( ) ;
26922693 fixture . componentInstance . control . setValue ( 0 ) ;
26932694 fixture . detectChanges ( ) ;
@@ -3238,6 +3239,8 @@ describe('MatSelect', () => {
32383239
32393240 let groupFixture = TestBed . createComponent ( SelectWithGroups ) ;
32403241 groupFixture . detectChanges ( ) ;
3242+ flush ( ) ;
3243+
32413244 trigger = groupFixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) ! . nativeElement ;
32423245 formField = groupFixture . debugElement . query ( By . css ( 'mat-form-field' ) ) ! . nativeElement ;
32433246
@@ -3905,7 +3908,10 @@ describe('MatSelect', () => {
39053908 } ) ;
39063909
39073910 describe ( 'with multiple selection' , ( ) => {
3908- beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [ MultiSelect ] ) ) ) ;
3911+ beforeEach ( async ( ( ) => configureMatSelectTestingModule ( [
3912+ MultiSelect ,
3913+ MultiSelectWithLotsOfPreselectedOptions
3914+ ] ) ) ) ;
39093915
39103916 let fixture : ComponentFixture < MultiSelect > ;
39113917 let testInstance : MultiSelect ;
@@ -4286,6 +4292,17 @@ describe('MatSelect', () => {
42864292 expect ( testInstance . control . value ) . toEqual ( [ ] ) ;
42874293 } ) ;
42884294
4295+ it ( 'should not throw with a large amount of preselected options' , fakeAsync ( ( ) => {
4296+ fixture . destroy ( ) ;
4297+
4298+ const lotsOfOptionsFixture = TestBed . createComponent ( MultiSelectWithLotsOfPreselectedOptions ) ;
4299+
4300+ expect ( ( ) => {
4301+ lotsOfOptionsFixture . detectChanges ( ) ;
4302+ flush ( ) ;
4303+ } ) . not . toThrow ( ) ;
4304+ } ) ) ;
4305+
42894306 } ) ;
42904307} ) ;
42914308
@@ -5062,3 +5079,17 @@ class SelectWithFormFieldLabel {
50625079class SelectWithNgIfAndLabel {
50635080 showSelect = true ;
50645081}
5082+
5083+ @Component ( {
5084+ template : `
5085+ <mat-form-field>
5086+ <mat-select multiple [ngModel]="value">
5087+ <mat-option *ngFor="let item of items" [value]="item">{{item}}</mat-option>
5088+ </mat-select>
5089+ </mat-form-field>
5090+ `
5091+ } )
5092+ class MultiSelectWithLotsOfPreselectedOptions {
5093+ items = new Array ( 1000 ) . fill ( 0 ) . map ( ( _ , i ) => i ) ;
5094+ value = [ ...this . items ] ;
5095+ }
0 commit comments