I was writing a test case and stumbled upon very weird thing. The scenario 
is that we have a search box in which when entered a list has to be updated 
accordingly. So I added a watch over the model and called the update 
function which updates the table in that. Now I was writing the test case 
for it which looks like:

it('search', function(){
        object = {
            states: states
        };
        spyOn(thisObject, 'updateLocations').and.callFake(function(){
            return $q.when();
        });
        thisObject.search.key = "";
        initiate_controller(object);
        $scope.$digest();
        spyOn(thisObject, 'updateLocations').and.callFake(function(){
            return $q.when();
        });
        thisObject.search.key = "Test";
        $scope.$digest();
        expect(thisObject.updateLocations).toHaveBeenCalled();
    });

Here I noticed that I had to spyOn multiple times. When I do a 
$scope.$digest the watch is called and the update function is called, if I 
remove the second spyOn the spec fails. It seems that spyOn needs to be 
done as many times as I am calling the function. Is that true? If so why ?

-- 
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.

Reply via email to