Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
FitseTLT committed Mar 10, 2025
1 parent 6d5b554 commit 907adaa
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/unit/SidebarUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,62 @@ describe('SidebarUtils', () => {
expect(result).toBe(true);
});

it('returns true when report has transaction thread notice type violation', async () => {
const MOCK_REPORT: Report = {
reportID: '1',
ownerAccountID: 12345,
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
stateNum: CONST.REPORT.STATE_NUM.OPEN,
statusNum: CONST.REPORT.STATUS_NUM.OPEN,
policyID: '6',
};

const MOCK_REPORTS: ReportCollectionDataSet = {
[`${ONYXKEYS.COLLECTION.REPORT}${MOCK_REPORT.reportID}` as const]: MOCK_REPORT,
};

const MOCK_REPORT_ACTIONS: ReportActions = {
// eslint-disable-next-line @typescript-eslint/naming-convention
'1': {
reportActionID: '1',
actionName: CONST.REPORT.ACTIONS.TYPE.IOU,
actorAccountID: 12345,
created: '2024-08-08 18:20:44.171',
},
};

const MOCK_TRANSACTION = {
transactionID: '1',
amount: 10,
modifiedAmount: 10,
reportID: MOCK_REPORT.reportID,
};

const MOCK_TRANSACTION_VIOLATIONS: TransactionViolationsCollectionDataSet = {
[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${MOCK_TRANSACTION.transactionID}` as const]: [
{
type: CONST.VIOLATION_TYPES.NOTICE,
name: CONST.VIOLATIONS.MODIFIED_AMOUNT,
showInReview: true,
},
],
};

await Onyx.multiSet({
...MOCK_REPORTS,
...MOCK_TRANSACTION_VIOLATIONS,
[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${MOCK_REPORT.reportID}` as const]: MOCK_REPORT_ACTIONS,
[ONYXKEYS.SESSION]: {
accountID: 12345,
},
[`${ONYXKEYS.COLLECTION.TRANSACTION}${MOCK_TRANSACTION.transactionID}` as const]: MOCK_TRANSACTION,
});

const result = SidebarUtils.shouldShowRedBrickRoad(MOCK_REPORT, MOCK_REPORT_ACTIONS, false, MOCK_TRANSACTION_VIOLATIONS as OnyxCollection<TransactionViolations>);

expect(result).toBe(true);
});

it('returns true when report has errors', () => {
const MOCK_REPORT: Report = {
reportID: '1',
Expand Down

0 comments on commit 907adaa

Please sign in to comment.