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');":
Member
20 Points
152 Posts
Jasmine test with angular ng-mock not working with controller and promise
Jun 09, 2017 02:50 PM|MarcosBR|LINK
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://www.bradoncode.com/blog/2015/07/13/unit-test-promises-angualrjs-q/
Please check my plunker: http://plnkr.co/edit/3IMzqH1yKW8kazZFWaA0?p=preview
Commenting the first test (it) of the controller.spec.js the other two test works. Any help, please?
Member
20 Points
152 Posts
Re: Jasmine test with angular ng-mock not working with controller and promise
Jun 11, 2017 09:18 AM|MarcosBR|LINK
Resolved my issue, the code is in the previous plunker.