Testing an function like this:
$scope.$watch('value', function(newVal, oldVal) {
if(newVal != oldVal)
service.setValue(newVal);
});
With a test like this:
it("$watch value",function(){
spyOn(service,'setValue').andCallThrough();
var controller=createController();
scope.value = true;
expect(service.setservicealue).toHaveBeenCalled();
})
And the spy is never triggered because of the condition. How can I trigger this watch event with the parameters in order to test if the service is called?
Aucun commentaire:
Enregistrer un commentaire