2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
2021-03-16 22:00:08 +01:00
|
|
|
import Button from '../../ui/button';
|
|
|
|
import SenderToRecipient from '../../ui/sender-to-recipient';
|
|
|
|
import TransactionBreakdown from '../transaction-breakdown';
|
|
|
|
import TransactionActivityLog from '../transaction-activity-log';
|
2021-04-28 21:53:59 +02:00
|
|
|
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction';
|
2021-06-08 17:25:48 +02:00
|
|
|
import { GAS_LIMITS } from '../../../../shared/constants/gas';
|
2022-05-31 18:46:38 +02:00
|
|
|
import TransactionStatus from '../transaction-status/transaction-status.component';
|
2021-03-16 22:00:08 +01:00
|
|
|
import TransactionListItemDetails from './transaction-list-item-details.component';
|
2018-08-31 21:36:36 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('TransactionListItemDetails Component', () => {
|
|
|
|
it('should render properly', () => {
|
2018-08-31 21:36:36 +02:00
|
|
|
const transaction = {
|
|
|
|
history: [],
|
|
|
|
id: 1,
|
2020-11-07 08:38:12 +01:00
|
|
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
2018-08-31 21:36:36 +02:00
|
|
|
txParams: {
|
|
|
|
from: '0x1',
|
2021-06-08 17:25:48 +02:00
|
|
|
gas: GAS_LIMITS.SIMPLE,
|
2018-08-31 21:36:36 +02:00
|
|
|
gasPrice: '0x3b9aca00',
|
|
|
|
nonce: '0xa4',
|
|
|
|
to: '0x2',
|
|
|
|
value: '0x2386f26fc10000',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-08-31 21:36:36 +02:00
|
|
|
|
2018-12-09 21:48:06 +01:00
|
|
|
const transactionGroup = {
|
|
|
|
transactions: [transaction],
|
|
|
|
primaryTransaction: transaction,
|
|
|
|
initialTransaction: transaction,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-12-09 21:48:06 +01:00
|
|
|
|
2018-08-31 21:36:36 +02:00
|
|
|
const wrapper = shallow(
|
|
|
|
<TransactionListItemDetails
|
2021-04-15 20:01:46 +02:00
|
|
|
onClose={() => undefined}
|
2020-05-26 22:49:11 +02:00
|
|
|
title="Test Transaction Details"
|
2020-01-16 04:34:32 +01:00
|
|
|
recipientAddress="0x1"
|
|
|
|
senderAddress="0x2"
|
2020-08-14 13:47:02 +02:00
|
|
|
tryReverseResolveAddress={() => undefined}
|
2018-12-09 21:48:06 +01:00
|
|
|
transactionGroup={transactionGroup}
|
2020-02-11 16:40:15 +01:00
|
|
|
senderNickname="sender-nickname"
|
|
|
|
recipientNickname="recipient-nickname"
|
2022-05-31 18:46:38 +02:00
|
|
|
transactionStatus={TransactionStatus}
|
2018-08-31 21:36:36 +02:00
|
|
|
/>,
|
2020-07-14 17:20:41 +02:00
|
|
|
{ context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } },
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
const child = wrapper.childAt(0);
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(child.hasClass('transaction-list-item-details')).toStrictEqual(true);
|
|
|
|
expect(child.find(Button)).toHaveLength(2);
|
|
|
|
expect(child.find(SenderToRecipient)).toHaveLength(1);
|
|
|
|
expect(child.find(TransactionBreakdown)).toHaveLength(1);
|
|
|
|
expect(child.find(TransactionActivityLog)).toHaveLength(1);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-08-31 21:36:36 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render a retry button', () => {
|
2018-08-31 21:36:36 +02:00
|
|
|
const transaction = {
|
|
|
|
history: [],
|
|
|
|
id: 1,
|
2020-11-07 08:38:12 +01:00
|
|
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
2018-08-31 21:36:36 +02:00
|
|
|
txParams: {
|
|
|
|
from: '0x1',
|
2021-06-08 17:25:48 +02:00
|
|
|
gas: GAS_LIMITS.SIMPLE,
|
2018-08-31 21:36:36 +02:00
|
|
|
gasPrice: '0x3b9aca00',
|
|
|
|
nonce: '0xa4',
|
|
|
|
to: '0x2',
|
|
|
|
value: '0x2386f26fc10000',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-08-31 21:36:36 +02:00
|
|
|
|
2018-12-09 21:48:06 +01:00
|
|
|
const transactionGroup = {
|
|
|
|
transactions: [transaction],
|
|
|
|
primaryTransaction: transaction,
|
|
|
|
initialTransaction: transaction,
|
|
|
|
nonce: '0xa4',
|
|
|
|
hasRetried: false,
|
|
|
|
hasCancelled: false,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-12-09 21:48:06 +01:00
|
|
|
|
2018-08-31 21:36:36 +02:00
|
|
|
const wrapper = shallow(
|
|
|
|
<TransactionListItemDetails
|
2021-04-15 20:01:46 +02:00
|
|
|
onClose={() => undefined}
|
|
|
|
title="Test Transaction Details"
|
2020-01-16 04:34:32 +01:00
|
|
|
recipientAddress="0x1"
|
|
|
|
senderAddress="0x2"
|
2020-08-14 13:47:02 +02:00
|
|
|
tryReverseResolveAddress={() => undefined}
|
2018-12-09 21:48:06 +01:00
|
|
|
transactionGroup={transactionGroup}
|
2019-11-19 00:23:41 +01:00
|
|
|
showSpeedUp
|
2020-02-11 16:40:15 +01:00
|
|
|
senderNickname="sender-nickname"
|
|
|
|
recipientNickname="recipient-nickname"
|
2022-05-31 18:46:38 +02:00
|
|
|
transactionStatus={TransactionStatus}
|
2018-08-31 21:36:36 +02:00
|
|
|
/>,
|
2020-07-14 17:20:41 +02:00
|
|
|
{ context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } },
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-08-31 21:36:36 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const child = wrapper.childAt(0);
|
2020-05-26 22:49:11 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(child.hasClass('transaction-list-item-details')).toStrictEqual(true);
|
|
|
|
expect(child.find(Button)).toHaveLength(3);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-07-30 02:42:29 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should disable the Copy Tx ID and View In Etherscan buttons when tx hash is missing', () => {
|
2019-07-30 02:42:29 +02:00
|
|
|
const transaction = {
|
|
|
|
history: [],
|
|
|
|
id: 1,
|
2021-04-15 20:01:46 +02:00
|
|
|
status: 'confirmed',
|
2019-07-30 02:42:29 +02:00
|
|
|
txParams: {
|
|
|
|
from: '0x1',
|
2021-06-08 17:25:48 +02:00
|
|
|
gas: GAS_LIMITS.SIMPLE,
|
2019-07-30 02:42:29 +02:00
|
|
|
gasPrice: '0x3b9aca00',
|
|
|
|
nonce: '0xa4',
|
|
|
|
to: '0x2',
|
|
|
|
value: '0x2386f26fc10000',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-07-30 02:42:29 +02:00
|
|
|
|
|
|
|
const transactionGroup = {
|
|
|
|
transactions: [transaction],
|
|
|
|
primaryTransaction: transaction,
|
|
|
|
initialTransaction: transaction,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-07-30 02:42:29 +02:00
|
|
|
|
|
|
|
const wrapper = shallow(
|
|
|
|
<TransactionListItemDetails
|
2021-04-15 20:01:46 +02:00
|
|
|
onClose={() => undefined}
|
|
|
|
title="Test Transaction Details"
|
2020-01-16 04:34:32 +01:00
|
|
|
recipientAddress="0x1"
|
|
|
|
senderAddress="0x2"
|
2020-08-14 13:47:02 +02:00
|
|
|
tryReverseResolveAddress={() => undefined}
|
2019-07-30 02:42:29 +02:00
|
|
|
transactionGroup={transactionGroup}
|
2020-02-11 16:40:15 +01:00
|
|
|
senderNickname="sender-nickname"
|
|
|
|
recipientNickname="recipient-nickname"
|
2022-05-31 18:46:38 +02:00
|
|
|
transactionStatus={TransactionStatus}
|
2019-07-30 02:42:29 +02:00
|
|
|
/>,
|
2020-07-14 17:20:41 +02:00
|
|
|
{ context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } },
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-07-30 02:42:29 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const child = wrapper.childAt(0);
|
2020-05-26 22:49:11 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(child.hasClass('transaction-list-item-details')).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
const buttons = child.find(Button);
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(buttons.at(0).prop('disabled')).toStrictEqual(true);
|
|
|
|
expect(buttons.at(1).prop('disabled')).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-07-30 02:42:29 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render functional Copy Tx ID and View In Etherscan buttons when tx hash exists', () => {
|
2019-07-30 02:42:29 +02:00
|
|
|
const transaction = {
|
|
|
|
history: [],
|
|
|
|
id: 1,
|
2021-04-15 20:01:46 +02:00
|
|
|
status: 'confirmed',
|
2019-07-30 02:42:29 +02:00
|
|
|
hash: '0xaa',
|
|
|
|
txParams: {
|
|
|
|
from: '0x1',
|
2021-06-08 17:25:48 +02:00
|
|
|
gas: GAS_LIMITS.SIMPLE,
|
2019-07-30 02:42:29 +02:00
|
|
|
gasPrice: '0x3b9aca00',
|
|
|
|
nonce: '0xa4',
|
|
|
|
to: '0x2',
|
|
|
|
value: '0x2386f26fc10000',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-07-30 02:42:29 +02:00
|
|
|
|
|
|
|
const transactionGroup = {
|
|
|
|
transactions: [transaction],
|
|
|
|
primaryTransaction: transaction,
|
|
|
|
initialTransaction: transaction,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-07-30 02:42:29 +02:00
|
|
|
|
|
|
|
const wrapper = shallow(
|
|
|
|
<TransactionListItemDetails
|
2021-04-15 20:01:46 +02:00
|
|
|
onClose={() => undefined}
|
|
|
|
title="Test Transaction Details"
|
2020-01-16 04:34:32 +01:00
|
|
|
recipientAddress="0x1"
|
|
|
|
senderAddress="0x2"
|
2020-08-14 13:47:02 +02:00
|
|
|
tryReverseResolveAddress={() => undefined}
|
2019-07-30 02:42:29 +02:00
|
|
|
transactionGroup={transactionGroup}
|
2020-02-11 16:40:15 +01:00
|
|
|
senderNickname="sender-nickname"
|
|
|
|
recipientNickname="recipient-nickname"
|
2022-05-31 18:46:38 +02:00
|
|
|
transactionStatus={TransactionStatus}
|
2019-07-30 02:42:29 +02:00
|
|
|
/>,
|
2020-07-14 17:20:41 +02:00
|
|
|
{ context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } },
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-07-30 02:42:29 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const child = wrapper.childAt(0);
|
2020-05-26 22:49:11 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(child.hasClass('transaction-list-item-details')).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
const buttons = child.find(Button);
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(buttons.at(0).prop('disabled')).toStrictEqual(false);
|
|
|
|
expect(buttons.at(1).prop('disabled')).toStrictEqual(false);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|