Jasmine testing does not recognize URL changing
<p>This is my <code>base.js</code>:</p>

<pre><code>self.logout = function(callback) {
     $http.post("api/logout")
     .then(function(response) {
         $window.location.href = "/";
     }, function(response) {
         self.accessErrors(response.data);
         callback();
      });
 };
</code></pre>

<p>and this is my <code>test_base.js</code>:</p>

<pre><code>it('logout() should POST to api/logout and redirect on success', function() {
    // I want to test if the logout(cb) function posts to api/logout and, on success, redirect to /
    $loc.path('/logout');
    mockBackend.expectPOST("api/logout").respond(204, {msg: 'No Content'});

    var cb = jasmine.createSpy('cb');
    BaseService.logout(cb);

    mockBackend.flush();
    expect($loc.path()).toEqual('/');
});
</code></pre>

<p>But I get an error when I test this. The error says:</p>

<pre><code>Expected '/logout' to equal '/'.
</code></pre>

<p>Any idea why it doesn't catch that URL changed to '/' when this line was executed:</p>

<pre><code>$window.location.href = "/";
</code></pre>