how to write a unit test for my toggletype function in a onchange dropDown

31 views Asked by At
<p-dropdown
        id="holiday-holiday-booking-modal-dropdown"
        [(ngModel)]="logic.requestType"
        [options]="requestTypes"
        [autoDisplayFirst]="false"
        required
        (onChange)="toggleType()"
        ngDefaultControl
      ></p-dropdown>

this is .html of angular page

 toggleType() {
    this.logic.modalBody.holidayBooking.holidayRequestType = this.logic.holidayRequestList[this.logic.requestType];
    this.validateHolidayRequest();
    this.setWorkingDaysForCountedHoliday();
  }

  validateHolidayRequest() {
    const holiday = this.logic.modalBody.holidayBooking;
    if (holiday.halfDay === false) {
      holiday.holidayCoefficient = HolidayCoefficient.FULL_DAY;
    }
    if (
      this.isHalfDayHolidayRequestValid() &&
      (!DateUtils.isInPast(holiday.startDate) ||
        holiday.holidayRequestType === HolidayType.SPECIAL_LEAVE ||
        holiday.holidayRequestType === HolidayType.UNPAID)
    ) {
      holiday.valid = true;
    } else {
      holiday.valid = false;
    }
  }

in this case toggletype() function has no input and output but it is in related with onchange of html tag.now I need to write a unit test to test this function and i don't know what should be my input and basically what should be expected to assert?

0

There are 0 answers