I have a function containing setTimeouts. I am trying to do unit testing but on the code coverage report it is always showing that the code inside the setTimeout is not executing.
Here is the code.
var func = function(str, type) {
var t1 = setTimeout(function() {
document.getElementById("ledtext").style.color = "#631313";
}, 100);
var t2 = setTimeout(function() {
document.getElementById("ledtext").style.color = "#ea0707";
}, 300);
var t3 = setTimeout(function() {
document.getElementById("ledtext").style.color = "#631313";
}, 500);
var t4 = setTimeout(function() {
document.getElementById("ledtext").style.color = "#ea0707";
localThisObject.startSequence(type);
}, 700);
}
Code Coverage
How to do unit testing of the above code using Karma-jasmine?
Here is a list of devDependencies:
"devDependencies": {
"jasmine-core": "^2.2.0",
"karma": "^0.12.31",
"karma-chrome-launcher": "^0.1.7",
"karma-coverage": "^1.1.1",
"karma-fixture": "^0.2.6",
"karma-htmlfile-reporter": "^0.3.5",
"karma-jasmine": "^0.3.5",
"karma-phantomjs-launcher": "^1.0.4"
}
jsfiddle
P.S.I have checked this question. It's not solving my problem.