Skip to content

Commit

Permalink
feat: Randomly exclude optional customer fields
Browse files Browse the repository at this point in the history
  • Loading branch information
lukehesluke committed Nov 9, 2023
1 parent 24af7d6 commit 71e54c7
Showing 1 changed file with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const { FlowStageRun } = require('./flow-stage-run');
/**
* @typedef {{
* '@type': 'Person' | 'Organization',
* identifier: string
* telephone: string,
* givenName: string,
* familyName: string,
* identifier?: string
* telephone?: string,
* givenName?: string,
* familyName?: string,
* email: string,
* }} Customer
*
Expand Down Expand Up @@ -158,14 +158,27 @@ const FlowStageUtils = {
* @returns {Customer}
*/
createRandomCustomerDetails() {
return {
/** @type {Customer} */
const person = {
'@type': 'Person',
email: faker.internet.email(),
telephone: faker.phone.phoneNumber(),
givenName: faker.name.lastName(),
familyName: faker.name.firstName(),
identifier: faker.datatype.uuid(),
};
if (Math.random() < 0.5) {
person.email = faker.internet.email();
}
if (Math.random() < 0.5) {
person.telephone = faker.phone.phoneNumber();
}
if (Math.random() < 0.5) {
person.givenName = faker.name.lastName();
}
if (Math.random() < 0.5) {
person.familyName = faker.name.firstName();
}
if (Math.random() < 0.5) {
person.identifier = faker.datatype.uuid();
}
return person;
},

/**
Expand Down

0 comments on commit 71e54c7

Please sign in to comment.