Estoy escribiendo un caso de prueba para la declaración condicional if = else en angular, el caso de prueba no tiene ningún error, pero cuando ejecuto la prueba ng, en la cobertura de código muestra que la declaración if-else no se ejecuta.
Por favor, ayúdame a entender cómo escribir el caso de estado para if-else
abajo está el código del caso de prueba que escribí ::
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); } });aquí está el componente. código de archivo ts para el mismo caso de prueba
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); } }