From da299866d393099776bc4a26fad5513618668701 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Wed, 28 May 2025 09:40:18 -0700 Subject: [PATCH] test(cdk/scrolling): Change test spying on tick tick is not called by schedulers anymore (they use an internal _tick) --- src/cdk/scrolling/virtual-scroll-viewport.spec.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/cdk/scrolling/virtual-scroll-viewport.spec.ts b/src/cdk/scrolling/virtual-scroll-viewport.spec.ts index a023cb718439..2357db6d4f29 100644 --- a/src/cdk/scrolling/virtual-scroll-viewport.spec.ts +++ b/src/cdk/scrolling/virtual-scroll-viewport.spec.ts @@ -7,7 +7,6 @@ import { ScrollingModule, } from '../scrolling'; import { - ApplicationRef, Component, Directive, TrackByFunction, @@ -814,25 +813,17 @@ describe('CdkVirtualScrollViewport', () => { })); describe('viewChange change detection behavior', () => { - let appRef: ApplicationRef; - - beforeEach(() => { - appRef = TestBed.inject(ApplicationRef); - }); - - it('should not run change detection if there are no viewChange listeners', fakeAsync(() => { + it('should not emit viewChange if there are no listeners', fakeAsync(() => { + const viewChangeSpy = spyOn(testComponent.virtualForOf.viewChange, 'next'); finishInit(fixture); testComponent.items = Array(10).fill(0); fixture.changeDetectorRef.markForCheck(); fixture.detectChanges(); flush(); - spyOn(appRef, 'tick'); - viewport.scrollToIndex(5); triggerScroll(viewport); - - expect(appRef.tick).not.toHaveBeenCalled(); + expect(viewChangeSpy).not.toHaveBeenCalled(); })); }); });