-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2e2dc4
commit 92409dc
Showing
7 changed files
with
126 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,12 @@ getActivityIds.mockResolvedValue({ data: ['someActivityid'] } as AxiosResponse); | |
getSubmissions.mockResolvedValue({ data: [{ activityId: 'someActivityid' }] } as AxiosResponse); | ||
|
||
interface FormValues { | ||
contacts: Array<Contact>; | ||
contactFirstName: string; | ||
contactLastName: string; | ||
contactEmail: string; | ||
contactPhoneNumber: string; | ||
contactApplicantRelationship: ProjectRelationship; | ||
contactPreference: ContactPreference; | ||
basic: { | ||
isRelated?: string; | ||
relatedActivityId?: string; | ||
|
@@ -51,18 +56,12 @@ interface FormValues { | |
|
||
function basicValidFormValues(): FormValues { | ||
return { | ||
contacts: [ | ||
{ | ||
contactId: '0', | ||
userId: undefined, | ||
firstName: 'testFirst', | ||
lastName: 'testLast', | ||
email: '[email protected]', | ||
phoneNumber: '1234567890', | ||
contactApplicantRelationship: ProjectRelationship.OWNER, | ||
contactPreference: ContactPreference.EMAIL | ||
} | ||
], | ||
contactFirstName: 'testFirst', | ||
contactLastName: 'testLast', | ||
contactEmail: '[email protected]', | ||
contactPhoneNumber: '1234567890', | ||
contactApplicantRelationship: ProjectRelationship.OWNER, | ||
contactPreference: ContactPreference.EMAIL, | ||
basic: { | ||
isRelated: 'Yes', | ||
enquiryDescription: 'test description', | ||
|
@@ -127,12 +126,12 @@ describe('EnquiryIntakeForm', () => { | |
const wrapper = mount(EnquiryIntakeForm, wrapperSettings()); | ||
await flushPromises(); | ||
|
||
const firstNameInput = wrapper.get('[name="contacts[0].firstName"]'); | ||
const lastNameInput = wrapper.get('[name="contacts[0].lastName"]'); | ||
const phoneInput = wrapper.get('[name="contacts[0].phoneNumber"]'); | ||
const emailInput = wrapper.get('[name="contacts[0].email"]'); | ||
const relationsInput = wrapper.get('[name="contacts[0].contactApplicantRelationship"]'); | ||
const contactInput = wrapper.get('[name="contacts[0].contactPreference"]'); | ||
const firstNameInput = wrapper.get('[name="contactFirstName"]'); | ||
const lastNameInput = wrapper.get('[name="contactLastName"]'); | ||
const phoneInput = wrapper.get('[name="contactPhoneNumber"]'); | ||
const emailInput = wrapper.get('[name="contactEmail"]'); | ||
const relationsInput = wrapper.get('[name="contactApplicantRelationship"]'); | ||
const contactInput = wrapper.get('[name="contactPreference"]'); | ||
const relatedInput = wrapper.findAll('[name="basic.isRelated"]'); | ||
|
||
expect(firstNameInput.isVisible()).toBeTruthy(); | ||
|
@@ -287,12 +286,12 @@ describe('EnquiryIntakeForm', () => { | |
...basicValidFormValues() | ||
}; | ||
|
||
modifiedFormValues[IntakeFormCategory.CONTACTS][0].email = 'bad@email'; | ||
modifiedFormValues.contactEmail = 'bad@email'; | ||
formRef.setValues(modifiedFormValues); | ||
|
||
const result = await formRef?.validate(); | ||
expect(Object.keys(result.errors).length).toBe(1); | ||
expect(result.errors[`${[IntakeFormCategory.CONTACTS]}[0].email`]).toBeTruthy(); | ||
expect(result.errors['contactEmail']).toBeTruthy(); | ||
}); | ||
|
||
it('generates missing first and last name missing error', async () => { | ||
|
@@ -305,15 +304,15 @@ describe('EnquiryIntakeForm', () => { | |
...basicValidFormValues() | ||
}; | ||
|
||
modifiedFormValues[IntakeFormCategory.CONTACTS][0].firstName = ''; | ||
modifiedFormValues[IntakeFormCategory.CONTACTS][0].lastName = ''; | ||
modifiedFormValues.contactFirstName = ''; | ||
modifiedFormValues.contactLastName = ''; | ||
|
||
formRef.setValues(modifiedFormValues); | ||
|
||
const result = await formRef?.validate(); | ||
expect(Object.keys(result.errors).length).toBe(2); | ||
expect(result.errors[`${[IntakeFormCategory.CONTACTS]}[0].firstName`]).toBeTruthy(); | ||
expect(result.errors[`${[IntakeFormCategory.CONTACTS]}[0].lastName`]).toBeTruthy(); | ||
expect(result.errors['contactFirstName']).toBeTruthy(); | ||
expect(result.errors['contactLastName']).toBeTruthy(); | ||
}); | ||
|
||
it('generates errors for isRelated', async () => { | ||
|
Oops, something went wrong.