My Code:
####
function spyOn$() {
var spy = spyOn(window, '$');
for (var i in jQuery) {
if (jQuery.hasOwnProperty(i)) $[i] = jQuery[i];
}
return spy;
}
jQuery = spyOn$().andCallFake(function (selector) {
switch (selector) {
case "#popupDiv":
return popupDiv;
break;
case popupDiv:
return popupDiv;
#####
the "popupDiv" is a own MockObject that simulates some Attributes of a real HTML Div.
Of course that DivMock must also implement all the Methods offered by jQuery and used in your code.
With my code you have to develope a MockObject that simulates the scrollTop()
the spyOn$ Method was posted in this group it is neccessary to avoid loosing all the properties from jQuery