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

237
Visualizações
Test case writing for If Else statement

I am writing test case for the conditional if=else statement in angular , test case is not having any error, but when I run the ng test then in code coverage its showing if-else statement is not executed.

Please help me to understand how to write the state case for if-else

bellow is the test case code I wrote ::

  it('Should initialize Edit or View screen based on redirect url', () => {
    const title = 'Edit';
    const titleView = 'View';
    if (title === 'Edit') {
      component.mode = 'Edit';
      expect(component.isEditScreen).toBe(true);
      expect(component.editModeDisabled).toBe(true);
      component.damageForm.controls['address'].disable();
      component.downclaim.disable();
      component.getEditDefaultDropdownValues();
      component.editDamageById(1);
    } else if (titleView === 'View') {
      expect(component.isViewScreen).toBe(true);
      expect(component.viewModeDisabled).toBe(true);
      component.damageForm.disable();
      component.viewDamageById(1);
    }
  });

here is the component. ts file code for same test case

  initEditOrView() {
    this.damageCode = this.route.snapshot.params.id;
    if (this.route.snapshot.data.title === 'Edit') {
      this.mode = 'Edit';
      this.isEditScreen = true;
      this.editModeDisabled = true;
      this.damageForm.controls['address'].disable();
      this.downclaim.disable();
      this.getEditDefaultDropdownValues();
      this.editDamageById(this.damageCode);
    } else if (this.route.snapshot.data.title === 'View') {
      this.isViewScreen = true;
      this.viewModeDisabled = true;
      this.damageForm.disable();
      this.viewDamageById(this.damageCode);
    }
  }
about 4 years ago · Juan Pablo Isaza
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