-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Showing
1 changed file
with
25 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1005,11 +1005,33 @@ describe('OptionsListUtils', () => { | |
}); | ||
|
||
describe('canCreateOptimisticPersonalDetailOption', () => { | ||
const VALID_EMAIL = '[email protected]'; | ||
it('should allow to create optimistic personal detail option if email is valid', () => { | ||
const currentUserEmail = '[email protected]'; | ||
const canCreate = OptionsListUtils.canCreateOptimisticPersonalDetailOption({ | ||
searchValue: VALID_EMAIL, | ||
currentUserOption: { | ||
login: currentUserEmail, | ||
} as ReportUtils.OptionData, | ||
// Note: in the past this would check for the existence of the email in the personalDetails list, this has changed. | ||
// We expect only filtered lists to be passed to this function, so we don't need to check for the existence of the email in the personalDetails list. | ||
// This is a performance optimization. | ||
personalDetailsOptions: [], | ||
recentReportOptions: [], | ||
}); | ||
|
||
expect(canCreate).toBe(true); | ||
}); | ||
|
||
it('should not allow to create option if email is an email of current user', () => { | ||
const currentUserEmail = '[email protected]'; | ||
const canCreate = OptionsListUtils.canCreateOptimisticPersonalDetailOption({ | ||
recentReportOptions: OPTIONS.reports, | ||
personalDetailsOptions: OPTIONS.personalDetails, | ||
currentUserOption: null, | ||
searchValue: currentUserEmail, | ||
recentReportOptions: [], | ||
personalDetailsOptions: [], | ||
currentUserOption: { | ||
login: currentUserEmail, | ||
} as ReportUtils.OptionData, | ||
}); | ||
|
||
expect(canCreate).toBe(false); | ||
|