66} from '@angular/forms' ;
77import { By } from '@angular/platform-browser' ;
88import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
9- import { BehaviorSubject , Observable } from 'rxjs' ;
9+ import { BehaviorSubject , Observable , firstValueFrom } from 'rxjs' ;
1010import { take } from 'rxjs/operators' ;
1111import { IgxSelectionAPIService } from '../core/selection' ;
1212import { IBaseCancelableBrowserEventArgs } from '../core/utils' ;
@@ -1532,7 +1532,7 @@ describe('igxCombo', () => {
15321532
15331533 productIndex = 42 ;
15341534 combo . virtualScrollContainer . scrollTo ( productIndex ) ;
1535- await wait ( ) ;
1535+ await firstValueFrom ( combo . virtualScrollContainer . chunkLoad ) ;
15361536 fixture . detectChanges ( ) ;
15371537 verifyComboData ( ) ;
15381538 // index is at bottom
@@ -1541,21 +1541,21 @@ describe('igxCombo', () => {
15411541
15421542 productIndex = 485 ;
15431543 combo . virtualScrollContainer . scrollTo ( productIndex ) ;
1544- await wait ( 30 ) ;
1544+ await firstValueFrom ( combo . virtualScrollContainer . chunkLoad ) ;
15451545 fixture . detectChanges ( ) ;
15461546 verifyComboData ( ) ;
15471547 expect ( combo . virtualizationState . startIndex + combo . virtualizationState . chunkSize - 1 )
15481548 . toEqual ( productIndex ) ;
15491549
15501550 productIndex = 873 ;
15511551 combo . virtualScrollContainer . scrollTo ( productIndex ) ;
1552- await wait ( ) ;
1552+ await firstValueFrom ( combo . virtualScrollContainer . chunkLoad ) ;
15531553 fixture . detectChanges ( ) ;
15541554 verifyComboData ( ) ;
15551555
15561556 productIndex = 649 ;
15571557 combo . virtualScrollContainer . scrollTo ( productIndex ) ;
1558- await wait ( ) ;
1558+ await firstValueFrom ( combo . virtualScrollContainer . chunkLoad ) ;
15591559 fixture . detectChanges ( ) ;
15601560 verifyComboData ( ) ;
15611561 } ) ;
@@ -1578,7 +1578,7 @@ describe('igxCombo', () => {
15781578
15791579 // Scroll selected items out of view
15801580 combo . virtualScrollContainer . scrollTo ( 40 ) ;
1581- await wait ( ) ;
1581+ await firstValueFrom ( combo . virtualScrollContainer . chunkLoad ) ;
15821582 fixture . detectChanges ( ) ;
15831583 combo . handleClearItems ( spyObj ) ;
15841584 expect ( combo . selection ) . toEqual ( [ ] ) ;
@@ -1604,7 +1604,7 @@ describe('igxCombo', () => {
16041604
16051605 // scroll to second selected item
16061606 combo . virtualScrollContainer . scrollTo ( 19 ) ;
1607- await wait ( 30 ) ;
1607+ await firstValueFrom ( combo . virtualScrollContainer . chunkLoad ) ;
16081608 fixture . detectChanges ( ) ;
16091609
16101610 const secondItem = combo . data [ combo . data . length - 1 ] ;
@@ -1633,7 +1633,7 @@ describe('igxCombo', () => {
16331633
16341634 // Scroll selected items out of view
16351635 combo . virtualScrollContainer . scrollTo ( 40 ) ;
1636- await wait ( ) ;
1636+ await firstValueFrom ( combo . virtualScrollContainer . chunkLoad ) ;
16371637 fixture . detectChanges ( ) ;
16381638 combo . select ( [ combo . data [ 0 ] [ valueKey ] , combo . data [ 1 ] [ valueKey ] ] ) ;
16391639 Object . assign ( expectedResults , {
@@ -1969,14 +1969,14 @@ describe('igxCombo', () => {
19691969 expect ( scrollbar . scrollTop ) . toEqual ( 0 ) ;
19701970 // Scroll to bottom;
19711971 UIInteractions . triggerEventHandlerKeyDown ( 'End' , dropdownContent ) ;
1972- await wait ( 30 ) ;
1972+ await firstValueFrom ( combo . virtualScrollContainer . chunkLoad ) ;
19731973 fixture . detectChanges ( ) ;
19741974 // Content was scrolled to bottom
19751975 expect ( scrollbar . scrollHeight - scrollbar . scrollTop ) . toEqual ( scrollbar . clientHeight ) ;
19761976
19771977 // Scroll to top
19781978 UIInteractions . triggerEventHandlerKeyDown ( 'Home' , dropdownContent ) ;
1979- await wait ( 30 ) ;
1979+ await firstValueFrom ( combo . virtualScrollContainer . chunkLoad ) ;
19801980 fixture . detectChanges ( ) ;
19811981 const dropdownContainer : HTMLElement = fixture . debugElement . query ( By . css ( `.${ CSS_CLASS_CONTAINER } ` ) ) . nativeElement ;
19821982 firstVisibleItem = dropdownContainer . querySelector ( `.${ CSS_CLASS_DROPDOWNLISTITEM } ` + ':first-child' ) ;
@@ -2013,14 +2013,14 @@ describe('igxCombo', () => {
20132013 expect ( scrollbar . scrollTop ) . toEqual ( 0 ) ;
20142014 // Scroll to bottom;
20152015 UIInteractions . triggerEventHandlerKeyDown ( 'End' , dropdownContent ) ;
2016- await wait ( ) ;
2016+ await firstValueFrom ( combo . virtualScrollContainer . chunkLoad ) ;
20172017 fixture . detectChanges ( ) ;
20182018 // Content was scrolled to bottom
20192019 expect ( scrollbar . scrollHeight - scrollbar . scrollTop ) . toEqual ( scrollbar . clientHeight ) ;
20202020
20212021 // Scroll to top
20222022 UIInteractions . triggerEventHandlerKeyDown ( 'Home' , dropdownContent ) ;
2023- await wait ( 30 ) ;
2023+ await firstValueFrom ( combo . virtualScrollContainer . chunkLoad ) ;
20242024 fixture . detectChanges ( ) ;
20252025 const dropdownContainer : HTMLElement = fixture . debugElement . query ( By . css ( `.${ CSS_CLASS_CONTAINER } ` ) ) . nativeElement ;
20262026 firstVisibleItem = dropdownContainer . querySelector ( `.${ CSS_CLASS_DROPDOWNLISTITEM } ` + ':first-child' ) ;
@@ -2066,7 +2066,7 @@ describe('igxCombo', () => {
20662066 spyOn ( combo . dropdown , 'onToggleClosing' ) . and . callThrough ( ) ;
20672067 spyOn ( combo . dropdown , 'onToggleClosed' ) . and . callThrough ( ) ;
20682068 combo . toggle ( ) ;
2069- await wait ( 30 ) ;
2069+ await wait ( ) ;
20702070 fixture . detectChanges ( ) ;
20712071 expect ( combo . collapsed ) . toEqual ( false ) ;
20722072 expect ( combo . dropdown . onToggleOpening ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -2075,17 +2075,17 @@ describe('igxCombo', () => {
20752075 expect ( virtDir . getScroll ( ) . scrollTop ) . toEqual ( 0 ) ;
20762076 expect ( vContainerScrollHeight ) . toBeGreaterThan ( combo . itemHeight ) ;
20772077 virtDir . getScroll ( ) . scrollTop = Math . floor ( vContainerScrollHeight / 2 ) ;
2078- await wait ( 30 ) ;
2078+ await firstValueFrom ( combo . virtualScrollContainer . chunkLoad ) ;
20792079 fixture . detectChanges ( ) ;
20802080 expect ( virtDir . getScroll ( ) . scrollTop ) . toBeGreaterThan ( 0 ) ;
20812081 UIInteractions . simulateClickEvent ( document . documentElement ) ;
2082- await wait ( 10 ) ;
2082+ await wait ( ) ;
20832083 fixture . detectChanges ( ) ;
20842084 expect ( combo . collapsed ) . toEqual ( true ) ;
20852085 expect ( combo . dropdown . onToggleClosing ) . toHaveBeenCalledTimes ( 1 ) ;
20862086 expect ( combo . dropdown . onToggleClosed ) . toHaveBeenCalledTimes ( 1 ) ;
20872087 combo . toggle ( ) ;
2088- await wait ( 30 ) ;
2088+ await wait ( ) ;
20892089 fixture . detectChanges ( ) ;
20902090 expect ( combo . collapsed ) . toEqual ( false ) ;
20912091 expect ( combo . dropdown . onToggleOpening ) . toHaveBeenCalledTimes ( 2 ) ;
@@ -2116,7 +2116,7 @@ describe('igxCombo', () => {
21162116 expect ( scrollbar . scrollTop ) . toEqual ( 0 ) ;
21172117
21182118 combo . virtualScrollContainer . scrollTo ( 16 ) ;
2119- await wait ( 30 ) ;
2119+ await firstValueFrom ( combo . virtualScrollContainer . chunkLoad ) ;
21202120 fixture . detectChanges ( ) ;
21212121 let selectedItem = fixture . debugElement . queryAll ( By . css ( `.${ CSS_CLASS_DROPDOWNLISTITEM } ` ) ) [ 1 ] ;
21222122 selectedItem . triggerEventHandler ( 'click' , UIInteractions . getMouseEvent ( 'click' ) ) ;
@@ -2126,13 +2126,13 @@ describe('igxCombo', () => {
21262126
21272127 const dropdownContent = fixture . debugElement . query ( By . css ( `.${ CSS_CLASS_CONTENT } ` ) ) ;
21282128 UIInteractions . triggerEventHandlerKeyDown ( 'End' , dropdownContent ) ;
2129- await wait ( 30 ) ;
2129+ await firstValueFrom ( combo . virtualScrollContainer . chunkLoad ) ;
21302130 fixture . detectChanges ( ) ;
21312131 // Content was scrolled to bottom
21322132 expect ( scrollbar . scrollHeight - scrollbar . scrollTop ) . toEqual ( scrollbar . clientHeight ) ;
21332133
21342134 combo . virtualScrollContainer . scrollTo ( 5 ) ;
2135- await wait ( 30 ) ;
2135+ await firstValueFrom ( combo . virtualScrollContainer . chunkLoad ) ;
21362136 fixture . detectChanges ( ) ;
21372137 selectedItem = fixture . debugElement . query ( By . css ( `.${ CSS_CLASS_SELECTED } ` ) ) ;
21382138 expect ( selectedItem . nativeElement . textContent ) . toEqual ( selectedItemText ) ;
0 commit comments