test methods with jQuery

I finally figured it out.
To stub/spy some function call that uses jQuery you have to:

1. require jsdom
2. require a copy of jQuery and call that wirh a fake DOM produced by
   jsDOM.
   Like so: global.jQuery=require("./jquery.js")(jsdom.jsdom().parentWindow);

The trick is that jQuery - when called in a node.js enviroment -
doesn't return some selector metches but a FACTORY to initialize
jQuery with an object that is a "window" and has a #document.
Look at the first few lines of the jQuery ource for more info.

When all is said and done sinon.js can easily spy on that prepared
jQuery:

var spy = sinon.spy(jQuery.prototype, "html");
jQuery("#selector").html("hi there!");
expect(spy).to.have.been.calledWith("hi there!");