-
Notifications
You must be signed in to change notification settings - Fork 32
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
81051cf
commit f8b33ad
Showing
2 changed files
with
87 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,7 +236,7 @@ describe('email validation', () => { | |
}); | ||
|
||
describe('validate emails and ids extraction', () => { | ||
it('extracted correct emails and ids', () => { | ||
it('extracted correct emails and ids from textarea and csv', () => { | ||
const formData = new FormData(); | ||
formData[EMAIL_ADDRESS_TEXT_FORM_DATA] = [ | ||
'[email protected],000000000000ABCABC', | ||
|
@@ -249,6 +249,7 @@ describe('email validation', () => { | |
'[email protected],000000000000ABCDDD', | ||
'[email protected],', | ||
'[email protected],000000000000ABCABC', | ||
'[email protected]', | ||
]; | ||
const userEmails = [ | ||
'[email protected]', | ||
|
@@ -258,19 +259,80 @@ describe('email validation', () => { | |
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
]; | ||
|
||
const ids = extractSalesforceIds(formData, userEmails); | ||
expect(ids).toEqual([ | ||
const salesforceIds = extractSalesforceIds(formData, userEmails); | ||
expect(salesforceIds).toEqual([ | ||
'000000000000ABCABC', | ||
'', | ||
'000000000000XYZXYZ', | ||
'000000000000YYYYYY', | ||
'000000000000ZZZZZZ', | ||
'000000000000ABCDDD', | ||
'', | ||
undefined, | ||
]); | ||
expect(userEmails.length).toEqual(ids.length); | ||
expect(userEmails.length).toEqual(salesforceIds.length); | ||
}); | ||
|
||
it('extracted correct emails and ids from textarea only', () => { | ||
const formData = new FormData(); | ||
formData[EMAIL_ADDRESS_TEXT_FORM_DATA] = [ | ||
'[email protected],000000000000ABCABC', | ||
'[email protected],', | ||
'[email protected],000000000000XYZXYZ', | ||
'[email protected]', | ||
].join('\n'); | ||
|
||
const userEmails = returnValidatedEmails(formData); | ||
expect(userEmails).toEqual(['[email protected]', '[email protected]', '[email protected]', '[email protected]']); | ||
const salesforceIds = extractSalesforceIds(formData, userEmails); | ||
expect(salesforceIds).toEqual([ | ||
'000000000000ABCABC', | ||
'', | ||
'000000000000XYZXYZ', | ||
undefined, | ||
]); | ||
expect(userEmails.length).toEqual(salesforceIds.length); | ||
}); | ||
|
||
it('extracted correct emails and ids from csv only', () => { | ||
const formData = new FormData(); | ||
formData[EMAIL_ADDRESS_CSV_FORM_DATA] = [ | ||
'[email protected],000000000000YYYYYY', | ||
'[email protected],', | ||
'[email protected],000000000000ZZZZZZ', | ||
'[email protected]', | ||
]; | ||
|
||
const userEmails = returnValidatedEmails(formData); | ||
expect(userEmails).toEqual(['[email protected]', '[email protected]', '[email protected]', '[email protected]']); | ||
const salesforceIds = extractSalesforceIds(formData, userEmails); | ||
expect(salesforceIds).toEqual([ | ||
'000000000000YYYYYY', | ||
'', | ||
'000000000000ZZZZZZ', | ||
undefined, | ||
]); | ||
expect(userEmails.length).toEqual(salesforceIds.length); | ||
}); | ||
|
||
it('returns no salesforce ids for emails only', () => { | ||
const formData = new FormData(); | ||
formData[EMAIL_ADDRESS_TEXT_FORM_DATA] = [ | ||
'[email protected]', | ||
'[email protected],', | ||
].join('\n'); | ||
formData[EMAIL_ADDRESS_CSV_FORM_DATA] = [ | ||
'[email protected],', | ||
'[email protected]', | ||
]; | ||
|
||
const userEmails = returnValidatedEmails(formData); | ||
expect(userEmails).toEqual(['[email protected]', '[email protected]', '[email protected]', '[email protected]']); | ||
const salesforceIds = extractSalesforceIds(formData, userEmails); | ||
expect(salesforceIds).toEqual(undefined); | ||
}); | ||
}); | ||
}); |