title: Angular promise not resolving in jasmine
body: <p>I have the following jasmine test:</p>
  
  <pre><code>it('should resolve promise', inject(function ($q, $rootScope) {
  
      function getPromise(){
          var deferred = $q.defer();
          setTimeout(function(){
              deferred.resolve(true);
          }, 1000);
          return deferred.promise;
      }
  
      var p = getPromise();
      var cb = jasmine.createSpy();
  
      runs(function(){
          expect(cb).not.toHaveBeenCalled();
  
          p.then(cb);
  
          $rootScope.$apply();
      });
  
      waitsFor(function(){
          return cb.callCount == 1;
      });
  
      runs(function(){
          expect(cb).toHaveBeenCalled();
  
          $rootScope.$apply();
      });
  
  }));
  </code></pre>
  
  <p>I thought $rootScope.$apply was supposed to resolve all outstanding promises, but somehow it does not happen in this test.</p>
  
  <p>How do i trigger promise resolving in a test like this? please help!</p>