-
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.
feat: refactor to make code human understandable
- Loading branch information
1 parent
dff4fe5
commit 772dff0
Showing
3 changed files
with
92 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import _ from 'lodash'; | ||
import { | ||
extractEmailAndIds, | ||
extractSalesforceIds, | ||
validateEmailAddresses, | ||
validateEmailAddressesFields, | ||
validateEmailTemplateFields, | ||
|
@@ -238,17 +238,39 @@ describe('email validation', () => { | |
describe('validate emails and ids extraction', () => { | ||
it('extracted correct emails and ids', () => { | ||
const formData = new FormData(); | ||
formData[EMAIL_ADDRESS_TEXT_FORM_DATA] = [ | ||
'[email protected],000000000000ABCABC', | ||
'[email protected],', | ||
'[email protected],000000000000XYZXYZ', | ||
].join('\n'); | ||
formData[EMAIL_ADDRESS_CSV_FORM_DATA] = [ | ||
'[email protected],000000000000ABCABC', | ||
'[email protected],000000000000XYZXYZ', | ||
'[email protected],000000000000ABCDDD', | ||
'[email protected],', | ||
'[email protected],000000000000YYYYYY', | ||
'[email protected],000000000000ZZZZZZ', | ||
'[email protected],000000000000ABCDDD', | ||
'[email protected],', | ||
'[email protected],000000000000ABCABC', | ||
]; | ||
const userEmails = [ | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
]; | ||
|
||
const data = extractEmailAndIds(formData); | ||
expect(data.emails.sort()).toEqual(['[email protected]', '[email protected]'].sort()); | ||
expect(data.ids).toEqual(['000000000000ABCABC', '000000000000XYZXYZ']); | ||
expect(data.haveSFIDs).toBeTruthy(); | ||
const ids = extractSalesforceIds(formData, userEmails); | ||
expect(ids).toEqual([ | ||
'000000000000ABCABC', | ||
'', | ||
'000000000000XYZXYZ', | ||
'000000000000YYYYYY', | ||
'000000000000ZZZZZZ', | ||
'000000000000ABCDDD', | ||
'', | ||
]); | ||
expect(userEmails.length).toEqual(ids.length); | ||
}); | ||
}); | ||
}); |