mercredi 6 novembre 2019

Why my angular test case for ternary condition is not working as expected?

I have to write a test case for ternary function below. For true condition my test case is running as expected by for false it is not working as expected. I am not sure why my logic is incorrect. What changes do I need to make it work?

  public getData(ball: any): string {
    return ball.data === 'N/A'
      ? `<div class="noad"><p class="percentage-value-template">&#8211; &#8211;</p></div>`
      : `<div class="noad"><p class="days">${ball.data}</p></div>`;
  }

For true condition the below test case works fine


 it('should return empty if data is N/A', () => {
    comp = 'N/A';
    expect(mask.getData(comp)).toBe('');
  });

For false condition it is giving error


  it('should return empty if data is available', () => {
    comp1 = 'ABC';
    expect(mask.getData(comp1)).toBe(comp1);
  });

Aucun commentaire:

Enregistrer un commentaire