title: How can I test if a method was called with toHaveBeenCalled ? angular
body: <p>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</p>
  <pre><code> changePage(event) {
      this.currentPages = event.currentPage - 1;
    }
  </code></pre>
  <p>And this is my test</p>
  <pre><code>it('Should call the function',()=&gt;{
      const newPage = {
        currentPage:1
      }
      component.changePage(newPage);
      expect(component.currentPages).toEqual(0);
      expect(component.changePage).toHaveBeenCalled();
    })
  </code></pre>
  <p><a href="https://i.stack.imgur.com/2Juc7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2Juc7.png" alt="enter image description here" /></a></p>