Skip to content

Commit bb69546

Browse files
authored
[WALL] Lubega / WALL-2987 / TransactionStatusError unit test (#13061)
* chore: transaction status error unit test * fix: applied comments * Merge branch 'master' of github.com:binary-com/deriv-app into WALL-2987/transaction-status-error-unit-test * fix: cleaned up code * fix: rerun workflow
1 parent a0aa511 commit bb69546

File tree

2 files changed

+46
-20
lines changed

2 files changed

+46
-20
lines changed

packages/wallets/src/features/cashier/modules/TransactionStatus/components/CryptoTransaction/__tests__/CryptoTransaction.spec.tsx

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,22 @@ jest.mock('../../../../../../../components/ModalProvider', () => ({
1919
}));
2020

2121
const mockTransaction = {
22-
address_hash: '1234567890',
23-
address_url: 'https://example.com/address',
22+
address_hash: '',
23+
address_url: '',
2424
amount: 0.0002,
25-
description: 'Transaction description',
26-
formatted_address_hash: 'abc123',
27-
formatted_amount: '0.0002 BTC',
25+
description: '',
26+
formatted_address_hash: '',
27+
formatted_amount: '',
2828
formatted_confirmations: 'Pending',
2929
formatted_transaction_hash: 'Pending',
30-
id: '123',
30+
id: '',
3131
is_deposit: false,
3232
is_valid_to_cancel: 1 as const,
3333
is_withdrawal: true,
3434
status_code: 'LOCKED' as const,
35-
status_message:
36-
"We're reviewing your withdrawal request. You may still cancel this transaction if you wish. Once we start processing, you won't be able to cancel.",
37-
status_name: 'In review',
38-
submit_date: 1705399737,
35+
status_message: '',
36+
status_name: '',
37+
submit_date: 123456,
3938
transaction_type: 'withdrawal' as const,
4039
};
4140

@@ -60,23 +59,22 @@ describe('CryptoTransaction', () => {
6059

6160
it('should render component with correct properties for deposit type transaction', () => {
6261
const mockDepositTransaction = {
63-
address_hash: '1234567890',
64-
address_url: 'https://example.com/address',
62+
address_hash: '',
63+
address_url: '',
6564
amount: 0.0002,
66-
description: 'Transaction description',
67-
formatted_address_hash: 'abc123',
68-
formatted_amount: '0.0002 BTC',
65+
description: '',
66+
formatted_address_hash: '',
67+
formatted_amount: '',
6968
formatted_confirmations: 'Pending',
7069
formatted_transaction_hash: 'Pending',
71-
id: '123',
70+
id: '',
7271
is_deposit: true,
7372
is_valid_to_cancel: 1 as const,
7473
is_withdrawal: false,
7574
status_code: 'LOCKED' as const,
76-
status_message:
77-
"We're reviewing your deposit request. You may still cancel this transaction if you wish. Once we start processing, you won't be able to cancel.",
78-
status_name: 'In review',
79-
submit_date: 1705399737,
75+
status_message: '',
76+
status_name: '',
77+
submit_date: 123456,
8078
transaction_type: 'withdrawal' as const,
8179
};
8280
(useCancelCryptoTransaction as jest.Mock).mockReturnValue({ mutate: jest.fn() });
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import { fireEvent, render, screen } from '@testing-library/react';
3+
import TransactionStatusError from '../TransactionStatusError';
4+
5+
describe('TransactionStatusError', () => {
6+
it('should render component correctly', () => {
7+
const mockRefresh = jest.fn();
8+
9+
render(<TransactionStatusError refresh={mockRefresh} />);
10+
11+
expect(screen.getByText('Unfortunately, we cannot retrieve the information at this time.')).toBeInTheDocument();
12+
expect(screen.getByText('Refresh')).toBeInTheDocument();
13+
});
14+
15+
it('should render refresh function on click of refresh button', () => {
16+
const mockRefresh = jest.fn();
17+
18+
render(<TransactionStatusError refresh={mockRefresh} />);
19+
20+
expect(screen.getByText('Unfortunately, we cannot retrieve the information at this time.')).toBeInTheDocument();
21+
22+
const refreshButton = screen.getByText('Refresh');
23+
expect(refreshButton).toBeInTheDocument();
24+
25+
fireEvent.click(refreshButton);
26+
expect(mockRefresh).toHaveBeenCalledTimes(1);
27+
});
28+
});

0 commit comments

Comments
 (0)