so I have this function within component:
move: function() {
var elemStyle = document.querySelector('#bar');
var width = 1;
var id = setInterval(function() {
if (width >= 100) {
clearInterval(id);
} else {
width++;
elemStyle.style.width = width + '%';
}
}, 20);
}
And I am writing tests to validate it. So far so good, but the only problems I am getting are the following:
-
It is saying that I am not Branch testing correctly (at 0%. which I assume has to do with the IF statement inside the setInterval anonymous function)
-
I have no idea how to test the anonymous function within setInterval, and much less the if statement.
I have succesfully tested the behaviour of the function itself (in this case, increase the width of a given element up to 100%), but I get this complaint about lack of branch testing. I have tried adding a return value after the clearInterval(id), but can't get it to work. What can I do? Any help will be appreciated.
Aucun commentaire:
Enregistrer un commentaire