so I have the following test in jasmine:
$httpBackend.whenPOST('/api/userdata/saveuser').respond({ 'result': 'true' })
it('should save the new or updated user', function () {
var controller = createController();
$httpBackend.flush();
spyOn(controller, 'saveUser');
controller.saveUser();
$httpBackend.flush();
expect(controller.saveUser).toHaveBeenCalled();
})
When I go to perform the FLUSH after the saveUser I get the famous 'no pending requests to flush'. The controller function looks like the following:
user.saveUser = function () {
userDataService.saveUser(user.data).then(function (result) {
$state.go("license", { guid: user.data.user.account });
});
};
Of course notice that I am not using $scope anywhere in my controller.
Don't get it!! I tried to put some console.log statements in the controller to see if it was hitting it... and I don't see it going into the procedure. YET the expect(controller.saveUser).toHaveBeenCalled() is successful.
Here is the dataservice:
function saveUser(user) {
return $http.post("/api/userdata/saveuser", user.data).success(returndata).error(returnerror)
};
UGGH Why is this happening????
Aucun commentaire:
Enregistrer un commentaire