Skip to content

Commit

Permalink
do not use ageType to simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria Lorena Rodriguez Viruel authored and Maria Lorena Rodriguez Viruel committed Nov 19, 2024
1 parent f13cda8 commit 08f0895
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions tests/factories/cht/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,8 @@ const createAdditionalPersons = (nbrPersons, clinic, nameList, dateOfBirthList)
.from({ length: nbrPersons })
.map((_, i) => {
const additionalPhoneNumber = PHONE_NUMBERS[i % PHONE_NUMBERS.length];
let name;
let date_of_birth;
if (ageType === 'kid') {
name = ADDITIONAL_KID_FIRST_NAMES[i % ADDITIONAL_KID_FIRST_NAMES.length];
date_of_birth = DATE_OF_BIRTHS_KIDS[i % DATE_OF_BIRTHS_KIDS.length];
} else if (ageType === 'adult') {
name = ADDITIONAL_WOMAN_FIRST_NAMES[i % ADDITIONAL_WOMAN_FIRST_NAMES.length];
date_of_birth = DATE_OF_BIRTHS_ADULTS[i % DATE_OF_BIRTHS_ADULTS.length];
}

const name = nameList[i % nameList.length];
const date_of_birth = dateOfBirthList[i % dateOfBirthList.length];
return personFactory.build({
parent: { _id: clinic._id, parent: clinic.parent },
name: `${name} ${clinic.last_name}`,
Expand All @@ -149,17 +141,17 @@ const createAdditionalPersons = (nbrPersons, clinic, nameList, dateOfBirthList)

const createAdditionalKid = (nbrPersons, clinic) => {
return createAdditionalPersons(
nbrPersons,
clinic,
ADDITIONAL_KID_FIRST_NAMES,
nbrPersons,
clinic,
ADDITIONAL_KID_FIRST_NAMES,
DATE_OF_BIRTHS_KIDS
);
};

const createAdditionalWoman = (nbrPersons, clinic) => {
return createAdditionalPersons(
nbrPersons,
clinic,
nbrPersons,
clinic,
ADDITIONAL_WOMAN_FIRST_NAMES,
DATE_OF_BIRTHS_ADULTS,
);
Expand Down

0 comments on commit 08f0895

Please sign in to comment.