title: How to mock `angular.element`
body: <p>In a service I have the following code snippet</p>
  
  <pre><code>angular.element('html, body').animate({
          scrollTop: this.parentHeight + ... - ...
      }, 500);
  </code></pre>
  
  <p>In my unit test I want to check if the correct values are given to the <code>animate</code> function. But how can I mock or spy this <code>animate</code> function ? I can think of something like this:</p>
  
  <pre><code>beforeEach(() =&gt; {
      angular.element = () =&gt; {
          return { animate: (options) =&gt; { .. }
      }
  });
  </code></pre>
  
  <p>or better (but not working)</p>
  
  <pre><code>  spyOn(angular.element('html, body'), 'animate');
  </code></pre>
  
  <p>Is there a better (angular) way to do this ?</p>