Within a service, the code snippet below is present:
angular.element('html, body').animate({
scrollTop: this.parentHeight + ... - ...
}, 500);
When writing unit tests, I am trying to verify if the values passed to the animate
function are correct. But how can I simulate or monitor this animate
function? One approach could be like so:
beforeEach(() => {
angular.element = () => {
return { animate: (options) => { .. }
}
});
Alternatively, though not functioning as intended:
spyOn(angular.element('html, body'), 'animate');
Is there a more effective (angular) way to accomplish this task?