title: Testing a whole page redirect in qUnit
body: <p>I have the following function</p>
  
  <pre><code>var redirect = function() {
      window.location.href = "http://www.google.com";
  }
  </code></pre>
  
  <p>I want to test this function using qUnit.</p>
  
  <p>The problem is, when I call up the HTML document in which my tests run, as soon as it gets to the test that calls <code>redirect()</code>, the browser loads google.com. What I would like to do is mock out window.location.href somehow so that it doesn't redirect, and so I can check that it was set to the proper value.</p>
  
  <p>Rewriting this in a manner that it would be more testable would be an acceptable answer and is welcomed. Since I am using qUnit, some jQuery magic would be appropriate, as would some old fashioned refactoring. Adding a custom setter for window.location.href was suggested, but I couldn't figure out how to get this to work.</p>
  
  <p>Please, no suggestions of changing the behavior of my code.</p>