Skip to content

Commit

Permalink
fix up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hannojg committed Dec 20, 2024
1 parent 94d5a33 commit fa3d283
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions tests/unit/OptionsListUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fa3d283

Please sign in to comment.