Skip to content

Commit 496b824

Browse files
committed
update test
1 parent e6db42c commit 496b824

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

tests/actions/IOU/PerDiemTest.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
33
import type {RequestMoneyParticipantParams} from '@libs/actions/IOU';
44
import type {PerDiemExpenseTransactionParams} from '@libs/actions/IOU/PerDiem';
55
import {addSubrate, clearSubrates, computePerDiemExpenseAmount, getPerDiemExpenseInformation, removeSubrate, submitPerDiemExpense, updateSubrate} from '@libs/actions/IOU/PerDiem';
6+
import * as ReportUtils from '@libs/ReportUtils';
67
import CONST from '@src/CONST';
78
import DateUtils from '@src/libs/DateUtils';
89
import ONYXKEYS from '@src/ONYXKEYS';
@@ -335,6 +336,55 @@ describe('PerDiem', () => {
335336
expect(currencyUpdate?.value).toEqual([testCurrency, ...initialCurrencies]);
336337
});
337338

339+
it('should forward conciergeReportID to buildOptimisticReportPreview', () => {
340+
const conciergeReportID = 'concierge_report_999';
341+
const buildPreviewSpy = jest.spyOn(ReportUtils, 'buildOptimisticReportPreview');
342+
343+
const mockTransactionParams: PerDiemExpenseTransactionParams = {
344+
comment: '',
345+
currency: CONST.CURRENCY.USD,
346+
created: '2024-02-02',
347+
category: 'Meals',
348+
tag: '',
349+
customUnit: {
350+
customUnitID: 'per_diem_unit',
351+
customUnitRateID: 'rate_1',
352+
name: CONST.CUSTOM_UNITS.NAME_PER_DIEM_INTERNATIONAL,
353+
attributes: {dates: {start: '2024-02-02', end: '2024-02-02'}},
354+
subRates: [],
355+
quantity: 1,
356+
},
357+
billable: false,
358+
attendees: [],
359+
reimbursable: true,
360+
};
361+
362+
getPerDiemExpenseInformation({
363+
parentChatReport: {} as OnyxEntry<Report>,
364+
transactionParams: mockTransactionParams,
365+
participantParams: {
366+
payeeAccountID: 123,
367+
payeeEmail: 'payee@example.com',
368+
participant: {accountID: 123, login: 'payee@example.com'},
369+
} as unknown as RequestMoneyParticipantParams,
370+
recentlyUsedParams: {},
371+
isASAPSubmitBetaEnabled: false,
372+
currentUserAccountIDParam: 123,
373+
currentUserEmailParam: 'payee@example.com',
374+
hasViolations: false,
375+
policyRecentlyUsedCurrencies: [],
376+
quickAction: undefined,
377+
betas: [CONST.BETAS.ALL],
378+
personalDetails: {123: {accountID: 123, login: 'payee@example.com'}},
379+
conciergeReportID,
380+
});
381+
382+
const previewCallWithConcierge = buildPreviewSpy.mock.calls.find((args) => args.at(6) === conciergeReportID);
383+
expect(previewCallWithConcierge).toBeDefined();
384+
385+
buildPreviewSpy.mockRestore();
386+
});
387+
338388
it('should return correct per diem expense information with new chat report', () => {
339389
// Given: Mock data for per diem expense
340390
const mockCustomUnit = {

0 commit comments

Comments
 (0)