-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11612 from Expensify/tgolen-fix-hasoutstandingious
Fix the broken logic for if a report has an outstanding IOU
- Loading branch information
Showing
2 changed files
with
88 additions
and
4 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 |
---|---|---|
|
@@ -4,6 +4,7 @@ import CONST from '../../src/CONST'; | |
import ONYXKEYS from '../../src/ONYXKEYS'; | ||
import * as ReportUtils from '../../src/libs/ReportUtils'; | ||
import waitForPromisesToResolve from '../utils/waitForPromisesToResolve'; | ||
import * as LHNTestUtils from '../utils/LHNTestUtils'; | ||
|
||
const currentUserEmail = '[email protected]'; | ||
const participantsPersonalDetails = { | ||
|
@@ -223,4 +224,82 @@ describe('ReportUtils', () => { | |
}); | ||
}); | ||
}); | ||
|
||
describe('hasOutstandingIOU', () => { | ||
it('returns false when there is no report', () => { | ||
expect(ReportUtils.hasOutstandingIOU()).toBe(false); | ||
}); | ||
it('returns false when the report has no iouReportID', () => { | ||
const report = LHNTestUtils.getFakeReport(); | ||
expect(ReportUtils.hasOutstandingIOU(report)).toBe(false); | ||
}); | ||
it('returns false when there is no iouReports collection', () => { | ||
const report = { | ||
...LHNTestUtils.getFakeReport(), | ||
iouReportID: '1', | ||
}; | ||
expect(ReportUtils.hasOutstandingIOU(report)).toBe(false); | ||
}); | ||
it('returns false when there is no matching IOU report', () => { | ||
const report = { | ||
...LHNTestUtils.getFakeReport(), | ||
iouReportID: '1', | ||
}; | ||
const iouReports = {}; | ||
expect(ReportUtils.hasOutstandingIOU(report, undefined, iouReports)).toBe(false); | ||
}); | ||
it('returns false when the matched IOU report does not have an owner email', () => { | ||
const report = { | ||
...LHNTestUtils.getFakeReport(), | ||
iouReportID: '1', | ||
}; | ||
const iouReports = { | ||
reportIOUs_1: { | ||
reportID: '1', | ||
}, | ||
}; | ||
expect(ReportUtils.hasOutstandingIOU(report, undefined, iouReports)).toBe(false); | ||
}); | ||
it('returns false when the matched IOU report does not have an owner email', () => { | ||
const report = { | ||
...LHNTestUtils.getFakeReport(), | ||
iouReportID: '1', | ||
}; | ||
const iouReports = { | ||
reportIOUs_1: { | ||
reportID: '1', | ||
ownerEmail: '[email protected]', | ||
}, | ||
}; | ||
expect(ReportUtils.hasOutstandingIOU(report, '[email protected]', iouReports)).toBe(false); | ||
}); | ||
it('returns true when the report has an oustanding IOU', () => { | ||
const report = { | ||
...LHNTestUtils.getFakeReport(), | ||
iouReportID: '1', | ||
hasOutstandingIOU: true, | ||
}; | ||
const iouReports = { | ||
reportIOUs_1: { | ||
reportID: '1', | ||
ownerEmail: '[email protected]', | ||
}, | ||
}; | ||
expect(ReportUtils.hasOutstandingIOU(report, '[email protected]', iouReports)).toBe(true); | ||
}); | ||
it('returns false when the report has no oustanding IOU', () => { | ||
const report = { | ||
...LHNTestUtils.getFakeReport(), | ||
iouReportID: '1', | ||
hasOutstandingIOU: false, | ||
}; | ||
const iouReports = { | ||
reportIOUs_1: { | ||
reportID: '1', | ||
ownerEmail: '[email protected]', | ||
}, | ||
}; | ||
expect(ReportUtils.hasOutstandingIOU(report, '[email protected]', iouReports)).toBe(false); | ||
}); | ||
}); | ||
}); |