mercredi 6 novembre 2019

How can I write test case for following angular function?

I have the following function in Angular. I need help writing test case to increase my code coverage. I am not sure from where to start. Any suggestions are appreciated. Thank you


     public Data(element: any, freq: freq, display: boolean): string {
        const getBack = freq === Labels.MONTHLY_freq ? element.getBack.Monthly : element.getBack.Quarterly;
        const chad = {
          markAmount: this.numberFormattingService.formatToNDecimalPlaces(
            null,
            getBack.Returns.TOOL.Portfolio,
            2,
            '%',
          ),
          bench: this.numberFormattingService.formatToNDecimalPlaces(
            null,
            getBack.Returns.TOOL.Portfolio,
            2,
            '%',
          ),
          sinceDate: this.i18nLabelService.interpolate(Labels.SINCE_DATE_STRING, {
            0: this.dateTimeFormattingService.dateShort(new Date(getBack.inceptionDate).toISOString()),
          }),
        };

        const show = display ? `<p class="pTemplate">${chad.bench}</p>` : '';

        return `
            <div class="len">
              <p class="pTemplate">${chad.markAmount}
              </p>
              <p class="cell-subtitle">${chad.sinceDate}</p>
              ${show}
            </div>
          `;
      }

Aucun commentaire:

Enregistrer un commentaire