Skip to content

Commit abd0e75

Browse files
committed
add test
1 parent e9f8517 commit abd0e75

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/cdk/scrolling/virtual-scroll-viewport.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {dispatchFakeEvent} from '@angular/cdk/testing';
99
import {
1010
Component,
1111
Input,
12+
NgZone,
1213
TrackByFunction,
1314
ViewChild,
1415
ViewContainerRef,
@@ -603,6 +604,13 @@ describe('CdkVirtualScrollViewport', () => {
603604
fixture.destroy();
604605
expect(dispatcher.deregister).toHaveBeenCalledWith(testComponent.viewport);
605606
})));
607+
608+
it('should emit on viewChange inside the Angular zone', fakeAsync(() => {
609+
const zoneTest = jasmine.createSpy('zone test');
610+
testComponent.virtualForOf.viewChange.subscribe(() => zoneTest(NgZone.isInAngularZone()));
611+
finishInit(fixture);
612+
expect(zoneTest).toHaveBeenCalledWith(true);
613+
}));
606614
});
607615

608616
describe('with RTL direction', () => {
@@ -766,6 +774,7 @@ function triggerScroll(viewport: CdkVirtualScrollViewport, offset?: number) {
766774
})
767775
class FixedSizeVirtualScroll {
768776
@ViewChild(CdkVirtualScrollViewport) viewport: CdkVirtualScrollViewport;
777+
@ViewChild(CdkVirtualForOf) virtualForOf: CdkVirtualForOf<any>;
769778
@ViewChild(CdkVirtualForOf, {read: ViewContainerRef}) virtualForViewContainer: ViewContainerRef;
770779

771780
@Input() orientation = 'vertical';

0 commit comments

Comments
 (0)