Skip to content

Commit a5ddcaa

Browse files
fix: add unit test
1 parent 0d97a9c commit a5ddcaa

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/ui/components/SearchActionsBarCreateButtonTest.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,32 @@ describe('SearchActionsBarCreateButton', () => {
264264
expect(screen.getByText(translateLocal('report.newReport.createReport'))).toBeOnTheScreen();
265265
});
266266

267+
it('should call startMoneyRequest when "Create expense" is pressed', async () => {
268+
mockUsePolicyForMovingExpenses.mockReturnValue({
269+
policyForMovingExpensesID: MOCK_POLICY_ID,
270+
policyForMovingExpenses: MOCK_POLICY,
271+
shouldSelectPolicy: false,
272+
});
273+
274+
await act(async () => {
275+
await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${MOCK_POLICY_ID}`, MOCK_POLICY);
276+
});
277+
await waitForBatchedUpdatesWithAct();
278+
279+
renderComponent();
280+
await waitForBatchedUpdatesWithAct();
281+
282+
const createButton = screen.getByText(translateLocal('common.create'));
283+
fireEvent.press(createButton);
284+
await waitForBatchedUpdatesWithAct();
285+
286+
const createExpenseItem = screen.getByText(translateLocal('iou.createExpense'));
287+
fireEvent.press(createExpenseItem, createMockPressEvent(createExpenseItem));
288+
await waitForBatchedUpdatesWithAct();
289+
290+
expect(mockInterceptAnonymousUser).toHaveBeenCalled();
291+
});
292+
267293
it('should navigate to workspace selector when owner billing is restricted and multiple workspaces exist', async () => {
268294
// Given the current user owns a workspace that is past due billing with an outstanding amount
269295
const pastDueGracePeriod = getUnixTime(subDays(new Date(), 3));

0 commit comments

Comments
 (0)