javascript - How to unit test an asynchronus factory which uses another factory in AngularJS? -
    i trying write unit tests databasecontacts factory, , lost how write them, there number of complications.   here factory want test:    .factory('databasecontacts',     function (getdatabasecontactsfromdb ){       return {        getcontacts: function(){          var dbcontacts = getdatabasecontactsfromdb.query();          return dbcontacts.$promise.then(function(result){            return result;          });        },        removecontact: function (contact){          getdatabasecontactsfromdb.remove(contact);        },        addcontact: function (contact){          var addedcontact =  getdatabasecontactsfromdb.save(contact);          return addedcontact.$promise.then(function(result){            return result;          });        }      };  })   and here getdatabasecontactsfromdb:    .factory('getdatabasecontactsfromdb', function ($resource){    return $resource('http://localhost:8000/contacts/');  })   here's attempt @ setup test:    describe( 'd...