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

236
Vistas
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 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