Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda