Hi guys

I'm facing some weird behaviour when trying to mock a jQuery method 
(scrollTop) used in an angular directive.

I'm setting the spy like this:
spyOn($.fn, 'scrollTop').and.returnValue('100');

The test looks like this:
it('...', function() {
        spyOn($.fn, 'scrollTop').and.returnValue('100');
        // $('').scrollTop() returns 100 here!
        compiledElement = $compile(tpl)(scope);
        expect(jQuery.fn.scrollTop).toHaveBeenCalled();
});

When I call the scrollTop inside the test, it works fine as commented in 
the snippet above. But when my directive in test calls scrollTop, it seems 
to somehow circumventing the spy.

Do you have any idea what is happening here?

Any pointers are appreciated! :)
Ben

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to