'How to resolve condition coverage for following in angular unit testing
I need to write the angular unit test case for following function
public isCompletedPlan = (plan: TaxOptimizedStrategy): boolean =>
plan?.withdrawalOrderRecommendations?.length > 0 &&
plan?.wealthMetrics?.length > 0 &&
plan?.alphaMetrics?.length > 0;
if I remove the ? marks, it will cover the conditions and my unit test case is like,
let plan = { some values }
it('should be create', () => {
expect(service).toBeTruthy();
service.isCompletedPlan(plan);
expect(plan.withdrawalOrderRecommendations.length > 0 && plan.wealthMetrics.length> 0 &&
plan.alphaMetrics.length> 0).toBe(true);
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
