I'm working page auto scroll when click on the button and I'm using template variable as target point. How to write a unit testing for scrollToSecondPage
function which has template var as param.
app.component.html
<section>
<p>section 1</p>
<button (click)="scrollToSecondPage(slide2)">Go to section 2</button>
</section>
<section #slide2>
<p>section 2</p>
</section>
app.component.ts
scrollToSecondPage(el: any): void {
el.scrollIntoView({ behavior: 'smooth' });
}
app.component.spec.ts
it('should scroll down to section two', () => {
let component = fixture.componentInstance;
let spy = spyOn(component, 'scrollToSecondPage').and.callThrough();
expect(spy).toHaveBeenCalled();
});