I am trying to improve code coverage of Angular app. In code coverage it is mentioned that if else condition is not covered. Could anyone tell me how to do that? Feel free to ask for more code details.
public searchByText(textVal: any): void {
let matchedEquipments = [];
// **
if (this.model.searchText.length > 1) {
matchedEquipments = this.refineByText(textVal, this.equipments);
} else {
matchedEquipments = this.equipments;
}
// **
matchedEquipments = this.refineByPlant(this.model.plants, matchedEquipments);
matchedEquipments = this.refineByPlantIsland(this.model.plantIslands, matchedEquipments);
matchedEquipments = this.refineByProcess(this.model.processes, matchedEquipments);
matchedEquipments = this.refineByIndustry(this.model.divisions, matchedEquipments);
this.displayClientData(matchedEquipments);
this.updateSearchCounters(SelectionFilter.FreeText);
}
Spec:
it('verify the result with search', async(() => {
equipmentSelectionComponent.searchByText("123");
//equipmentSelectionComponent.model.searchText = "123";
expect(equipmentSelectionComponent.matchedData.length).toBeGreaterThan(0);
}));
.searchByText("")?