Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

220
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda