I have a function that update a variable, but in the coverage its show me that function as if I had not tried it. How can I test if a function was called ? This is my function
changePage(event) {
this.currentPages = event.currentPage - 1;
}
And this is my test
it('Should call the function',()=>{
const newPage = {
currentPage:1
}
component.changePage(newPage);
expect(component.currentPages).toEqual(0);
expect(component.changePage).toHaveBeenCalled();
})

You can spy the function to test whether it has been called or not. Over here you want the original function to be executed + it should get called. Thus you should call
callThrough()method on it.