'Not able write a jasmine test case for radiobutton, eventlistners and buttonclicks
Below is my code
I want to do Jasmine test on it and I was wondering if I use beforEach and afterEach or may be spyOn() on it? I get test to pass if expect(function).toEqual(false) , but whenever i use true it throws an error.
function getMealTypeChoice(selection) {
if (!selection) {
return false;
}
var foodChoices = document.radioForm.foodChoice;
for (var i = 0; i < foodChoices.length; i++) {
foodChoices[i].addEventListener('change', function () {
selectedOptionMsg.innerHTML = "Enjoy your " + this.value.charAt(0).toUpperCase() + this.value.slice(1) + " " + selection + "!!";
mealContainer.style.display = "block";
console.log(this.value)
displaySelectedMeal(selection, this.value)
scrollTop(1400);
});
}
}
Solution 1:[1]
If you're running it in browser you can add the selectedOptionMsg element and your buttons to your SpecRunner.html file and compare their values to expected?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Stefan Whittaker-Lee |
