Skip to content

Commit

Permalink
fixed flakey tx test
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan-defi committed Nov 19, 2024
1 parent 5e11e0d commit b8f0926
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/transaction/components/TransactionProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ describe('TransactionProvider', () => {
});

it('should emit onError when legacy transactions fail', async () => {
// need to mock sendWalletTransactions to prevent lifecycleStatus from being
// set to 'error' when sendWalletTransactions is called
const sendWalletTransactionsMock = vi.fn().mockResolvedValue(undefined);
(useSendWalletTransactions as ReturnType<typeof vi.fn>).mockReturnValue(
sendWalletTransactionsMock,
);
const onErrorMock = vi.fn();
(waitForTransactionReceipt as ReturnType<typeof vi.fn>).mockRejectedValue(
new Error('error getting transaction receipt'),
Expand All @@ -309,7 +315,12 @@ describe('TransactionProvider', () => {
);
fireEvent.click(button);
await waitFor(() => {
expect(onErrorMock).toHaveBeenCalled();
expect(sendWalletTransactionsMock).toHaveBeenCalled();
expect(onErrorMock).toHaveBeenCalledWith({
code: 'TmTPc01',
error: '{}',
message: 'Something went wrong. Please try again.',
});
});
});

Expand Down

0 comments on commit b8f0926

Please sign in to comment.