Hi all, I'm having some trouble testing a controller. I'm using jasmine-karma to do this unit test.
The form I'm trying to test is enhanced with a custom directive that I found on the web: http://blog.yodersolutions.com/bootstrap-form-validation-done-right-in-angularjs/ It was all going fine until calling one of the functions in my controller that has this line in it $scope.$broadcast('show-errors-reset'); Let me try and describe the setup (I based more or less everything on the examples of the custom directive): So I have the controller with this function in it: $scope.resetRegistrationForm = function() { $scope.$broadcast('show-errors-reset'); $scope.newUser = {}; }; And in the test: describe('reset', function(){ var $scope, controller; var incompleteFakeUser = { firstName:'John', lastName:'Do' }; beforeEach(function(){ $scope = {}; $scope.newUser = incompleteFakeUser; controller = $controller('registrationController', { $scope: $scope }); }); it('should reset the newUser', function(){ //expect($scope.newUser).toEqual(incompleteFakeUser); *//$scope.resetRegistrationForm();* //expect($scope.newUser).toEqual({}); }); }); The line I put in bold is the problem. That function has the broadcast line in it. I know that is the problem because creating a dummy function with a console.log( ) in it passes the test correctly. I gave little context, I know, but honestly I don't how much more you would need to know and the basic problem is related to the code I just posted. Hope someone sees the problem :) Sam -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
