title: How to create unit-testing for $http promise in AngularJS
body: <p>I have a service with a function to use $http with promise. And i want create a unit-testing with jasmine.  </p>
  
  <pre><code>account.service('AccountService', ['$q', '$http', function ($q, $http) {
      this.getServerDataForUrl = function (url) {
           var def = $q.defer();
           $http.get(url)
                .success(function (data) {
                     if (data) {
                        def.resolve(data);
                     } else {
                        def.reject();
                     }
                 })
                 .error(function (error) {
                     if (data) {
                        def.resolve(data);
                     } else {
                        def.resolve();
                     }
                  });
           return def.promise;
      };
  }]);
  </code></pre>
  
  <p><strong>UPDATE:</strong> Change something code when callback.<br>
  I've search about it but it not give me exactly function like this. Anyone give me some example to create unit-testing about it. I think this function is simple. Thanks.</p>