Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

222
Views
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);
    });
  }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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?

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!