title: Angular Jasmine unit test for promise
body: <p>I want to write a unit test that just displays the behavior of creating two promises, wrapping them up into one with $q.all and then test that the promises are both resolved at the same time.</p>
  
  <pre><code>  describe("Application controller", function() {
      var scope;
      var controller;
  
      beforeEach(module('my.namespace'));
  //this suite can be removed.
      describe("Application ", function() {
          beforeEach(
              inject(function ($rootScope, $controller,$q) {
                  scope = $rootScope.$new();
                  controller = $controller('Application', {
                      '$scope': scope
                  });
              }));
  
  
          it("should package two promises into one", function (done) {
              inject(function ($rootScope) {
                  setTimeout(function () {
                      $rootScope.$apply(function () {
                          var promiseOne = $q.defer(),
                              //promiseOneData;
                              promiseTwo = $q.defer();
                              //promiseTwoData
                          promiseOne.then(function(data){
                              promiseOne.resolve('promiseOne');
                              expect(1).toBe(1);
                          });
                          promiseTwo.then(function(data){
                              promiseTwoData.resolve('promiseTwo');
                          })
                          var allPromises = $q.all([promiseOne,promiseTwo]);
                          allPromises.then(function(data){
                              //data should contain an array of two empty elements for each promise
                              expect(data.length).toBe(2);
                          });
                          done();
                      });
                  }, 1000);
  
  
      })
  });
  </code></pre>
  
  <p>With this I get the error: <code>Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.</code>  I don't want to actually use a get request for anything here, I just need two promises to be resolved and then moved into one promise that contains both.  How can I do that with Angular and jasmine?</p>