title: Stub out a jQuery selector call?
body: <p>I'm trying to get better at unit testing my JavaScript. I have the following code:</p>
  
  <pre><code>var categoryVal = $('#category').val();
  if (categoryVal === '') { 
      doSomething();
  } 
  </code></pre>
  
  <p>My test runner doesn't have the <code>#category</code> input on the page, so how would I stub/mock out the jQuery selector here? I've looked at both the <a href="http://pivotal.github.com/jasmine/" rel="noreferrer">jasmin</a> and <a href="http://sinonjs.org/" rel="noreferrer">sinon</a> documentation, but can't figure out how to get them to work here, since their stubs operate on objects, which <code>$</code> is not.</p>