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
?