vendredi 7 juin 2019

Write a mocha unit test code for the following meteor code

I want to know how to write test code using mocha for the meteor function

  export const physicalToLogical = (physicalStatus, planningStartDate, planningEndDate) => {

    if(physicalStatus === STATUS_PHYSICAL_CREATING) {

         return STATUS_LOGICAL_CREATING;

    } else if (physicalStatus === STATUS_PHYSICAL_OPEN) {

        const now = new Date();

  if(planningStartDate.getTime() <= now && planningEndDate.getTime() > now) {

            return STATUS_LOGICAL_OPEN_FOR_PLAN;

        } else if(planningStartDate.getTime() > now) {

            return STATUS_LOGICAL_PROSPECT;
        }
        return STATUS_LOGICAL_REVIEW;

    } else if (physicalStatus === STATUS_PHYSICAL_CLOSED) {

        return STATUS_LOGICAL_CLOSED;

    } else if (physicalStatus === STATUS_PHYSICAL_ARCHIVED) {

        return STATUS_LOGICAL_ARCHIVED;
    }
    throw new Error("Not implemented yet");
};

Aucun commentaire:

Enregistrer un commentaire