vendredi 9 juin 2017

Jasmine test with angular ng-mock not working with controller and promise

I have been playing a bit with the following code and I am not able to find the issue, the test fails wit the following message: "Expected undefined not to be undefined."

I have a Service which returns a promise to my controller. In the controller, I am using $q.all to do some stuff immediately after I get the promise resolved.

I tried to follow this example, but the big difference I see is that in the example it has the call in the root of the controller and I have the service call inside of the method "$scope.CustomerTest" so I have this additional line to before the apply ( $scope.$apply() ) "$scope.CustomerTest('Mr');":

http://ift.tt/1K12ebF

Please check at my plunker:

<a href="http://ift.tt/2ra6P8u">Plunker</a> 

Commenting the first test (it) of the controller.spec.js the other two test works. Any help please?

Aucun commentaire:

Enregistrer un commentaire