mardi 7 avril 2015

AngularJS - Unit Test with $timeout

I have a directive that look like this:



angular.directive('myDirective', ['$compile','$timeout', function($compile,$timeout){
console.log("myDirective compile");
return {
link: function(scope, element) {
console.log("myDirective before timeout");
$timeout(function(){
console.log("myDirective after timeout");
});
}
};
}]);


When I do unit test with Karma-Jasmine, I get the LOG output of myDirective compile and myDirective before timeout. But no output for myDirective after timeout


How can I get the $timeout function to run in unit test?


Aucun commentaire:

Enregistrer un commentaire