Skip to content

Commit 891fd23

Browse files
committed
address comments
1 parent 6e79ab1 commit 891fd23

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,14 @@ describe('CdkVirtualScrollViewport', () => {
393393

394394
it('should recycle views when template cache is large enough to accommodate', fakeAsync(() => {
395395
testComponent.trackBy = i => i;
396-
spyOn(testComponent.cdkForOfViewContainer, 'createEmbeddedView').and.callThrough();
396+
const spy =
397+
spyOn(testComponent.cdkForOfViewContainer, 'createEmbeddedView').and.callThrough();
397398
finishInit(fixture);
398399

399400
// Should create views for the initial rendered items.
400401
expect(testComponent.cdkForOfViewContainer.createEmbeddedView).toHaveBeenCalledTimes(4);
401402

402-
(testComponent.cdkForOfViewContainer.createEmbeddedView as any).calls.reset();
403+
spy.calls.reset();
403404
triggerScroll(viewport, 10);
404405
fixture.detectChanges();
405406

@@ -408,7 +409,7 @@ describe('CdkVirtualScrollViewport', () => {
408409
// item is now partially on the screen at the bottom and so a new view is needed.
409410
expect(testComponent.cdkForOfViewContainer.createEmbeddedView).toHaveBeenCalledTimes(1);
410411

411-
(testComponent.cdkForOfViewContainer.createEmbeddedView as any).calls.reset();
412+
spy.calls.reset();
412413
const maxOffset =
413414
testComponent.itemSize * testComponent.items.length - testComponent.viewportSize;
414415
for (let offset = 10; offset <= maxOffset; offset += 10) {
@@ -424,13 +425,14 @@ describe('CdkVirtualScrollViewport', () => {
424425
it('should not recycle views when template cache is full', fakeAsync(() => {
425426
testComponent.trackBy = i => i;
426427
testComponent.templateCacheSize = 0;
427-
spyOn(testComponent.cdkForOfViewContainer, 'createEmbeddedView').and.callThrough();
428+
const spy =
429+
spyOn(testComponent.cdkForOfViewContainer, 'createEmbeddedView').and.callThrough();
428430
finishInit(fixture);
429431

430432
// Should create views for the initial rendered items.
431433
expect(testComponent.cdkForOfViewContainer.createEmbeddedView).toHaveBeenCalledTimes(4);
432434

433-
(testComponent.cdkForOfViewContainer.createEmbeddedView as any).calls.reset();
435+
spy.calls.reset();
434436
triggerScroll(viewport, 10);
435437
fixture.detectChanges();
436438

@@ -439,7 +441,7 @@ describe('CdkVirtualScrollViewport', () => {
439441
// item is now partially on the screen at the bottom and so a new view is needed.
440442
expect(testComponent.cdkForOfViewContainer.createEmbeddedView).toHaveBeenCalledTimes(1);
441443

442-
(testComponent.cdkForOfViewContainer.createEmbeddedView as any).calls.reset();
444+
spy.calls.reset();
443445
const maxOffset =
444446
testComponent.itemSize * testComponent.items.length - testComponent.viewportSize;
445447
for (let offset = 10; offset <= maxOffset; offset += 10) {

0 commit comments

Comments
 (0)