lundi 6 avril 2015

Angularjs unit test scope value

I have a directive that look like this:



angular.directive('myDirective', ['$compile', function($compile){
return {
link: function(scope, element, attr, controller) {
function update(){
if(scope.value == "A"){
scope.desc = "Welcome";
}else{
scope.desc = "Not Welcome";
}
}

scope.$watch('value', function(newValue, oldValue) {
update();
},true);

update();
}
};
}]);


How can I write an unit test that can verify the changes in scope.value will return the correct scope.desc?


Aucun commentaire:

Enregistrer un commentaire