Skip to content

Commit

Permalink
test: Fix flakiness in virtual scroll tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed May 24, 2024
1 parent 5bafb89 commit 1d63fa6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cdk/scrolling/virtual-scroll-viewport.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
tick,
waitForAsync,
} from '@angular/core/testing';
import {Subject, animationFrameScheduler} from 'rxjs';
import {Subject} from 'rxjs';
import {dispatchFakeEvent} from '../testing/private';

describe('CdkVirtualScrollViewport', () => {
Expand Down Expand Up @@ -1245,7 +1245,7 @@ function finishInit(fixture: ComponentFixture<any>) {
flush();

// Flush the initial fake scroll event.
animationFrameScheduler.flush();
tick(16); // flush animation frame;
flush();
fixture.changeDetectorRef.markForCheck();
fixture.detectChanges();
Expand All @@ -1257,7 +1257,7 @@ function triggerScroll(viewport: CdkVirtualScrollViewport, offset?: number) {
viewport.scrollToOffset(offset);
}
dispatchFakeEvent(viewport.scrollable.getElementRef().nativeElement, 'scroll');
animationFrameScheduler.flush();
tick(16); // flush animation frame;
}

@Component({
Expand Down

0 comments on commit 1d63fa6

Please sign in to comment.