How do you mock the second call to then in this code in an angular service.
myService.promise.then(function () {
userConfig = userService.getUserConfiguration();
}).then(function () {
//do more stuff
})
I know that I can mock the first call as follows:
beforeEach(inject(function ($q) {
var deferred = $q.defer();
spyOn(myService.promise, 'then').and.returnValue({$promise: deferred.promise});
deferred.resolve();
}));
Aucun commentaire:
Enregistrer un commentaire