I am attempting to write unit tests for the following function using Jasmine:
function toggleDisplay(divIdToShowHide, showHide) {
var divToShowHide = document.getElementById(divIdToShowHide);
if (showHide == "show")
divToShowHide.style.display = "block";
else if (showHide == "hide")
divToShowHide.style.display = "none";
else
divToShowHide.style.display = (divToShowHide.style.display == "block") ? "none" : "block";
var buttonForDiv = document.getElementById(divIdToShowHide + 'Button');
if (divToShowHide.style.display == "block")
buttonForDiv.innerHTML = "-";
else
buttonForDiv.innerHTML = "+";
}
I need to test this against a sample HTML code I have written containing various butttons. I am lost on how to get the jasmine tests for the code to actually run on the HTML(since it needs to getElementById). Is there a simple way to implement this?