I want to unit test a function that is called multiple times based on a response from another function.
Similar to my question: Call a promise function multiple times until condition met from another promise function.
Here is the function
var monitorProgress = function() {
return getActiveTasks().then(function(res) {
if(res.length > 0) {
progress = res[0].progress;
if(progress !== 100){
return $timeout(function(){
return monitorProgress(); // multiple calls
},1000);
}
else {
// exit
console.log("done");
}
}
else{
console.log("done");
}
});
};