You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
172 lines
4.8 KiB
172 lines
4.8 KiB
4 years ago
|
import React from 'react';
|
||
|
import { shallow } from 'enzyme';
|
||
4 years ago
|
import TransactionActivityLog from './transaction-activity-log.component';
|
||
6 years ago
|
|
||
4 years ago
|
describe('TransactionActivityLog Component', () => {
|
||
|
it('should render properly', () => {
|
||
6 years ago
|
const activities = [
|
||
|
{
|
||
|
eventKey: 'transactionCreated',
|
||
4 years ago
|
hash:
|
||
|
'0xe46c7f9b39af2fbf1c53e66f72f80343ab54c2c6dba902d51fb98ada08fe1a63',
|
||
6 years ago
|
id: 2005383477493174,
|
||
|
timestamp: 1543957986150,
|
||
6 years ago
|
value: '0x2386f26fc10000',
|
||
4 years ago
|
},
|
||
|
{
|
||
6 years ago
|
eventKey: 'transactionSubmitted',
|
||
4 years ago
|
hash:
|
||
|
'0xe46c7f9b39af2fbf1c53e66f72f80343ab54c2c6dba902d51fb98ada08fe1a63',
|
||
6 years ago
|
id: 2005383477493174,
|
||
|
timestamp: 1543957987853,
|
||
|
value: '0x1319718a5000',
|
||
4 years ago
|
},
|
||
|
{
|
||
6 years ago
|
eventKey: 'transactionResubmitted',
|
||
4 years ago
|
hash:
|
||
|
'0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
|
||
6 years ago
|
id: 2005383477493175,
|
||
|
timestamp: 1543957991563,
|
||
|
value: '0x1502634b5800',
|
||
4 years ago
|
},
|
||
|
{
|
||
6 years ago
|
eventKey: 'transactionConfirmed',
|
||
4 years ago
|
hash:
|
||
|
'0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
|
||
6 years ago
|
id: 2005383477493175,
|
||
|
timestamp: 1543958029960,
|
||
|
value: '0x1502634b5800',
|
||
6 years ago
|
},
|
||
4 years ago
|
];
|
||
6 years ago
|
|
||
|
const wrapper = shallow(
|
||
|
<TransactionActivityLog
|
||
6 years ago
|
activities={activities}
|
||
6 years ago
|
className="test-class"
|
||
6 years ago
|
inlineRetryIndex={-1}
|
||
|
inlineCancelIndex={-1}
|
||
|
nativeCurrency="ETH"
|
||
4 years ago
|
onCancel={() => undefined}
|
||
|
onRetry={() => undefined}
|
||
6 years ago
|
primaryTransactionStatus="confirmed"
|
||
6 years ago
|
/>,
|
||
4 years ago
|
{ context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } },
|
||
4 years ago
|
);
|
||
6 years ago
|
|
||
4 years ago
|
expect(wrapper.hasClass('transaction-activity-log')).toStrictEqual(true);
|
||
|
expect(wrapper.hasClass('test-class')).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should render inline retry and cancel buttons for earliest pending transaction', () => {
|
||
6 years ago
|
const activities = [
|
||
|
{
|
||
|
eventKey: 'transactionCreated',
|
||
|
hash: '0xa',
|
||
|
id: 1,
|
||
|
timestamp: 1,
|
||
|
value: '0x1',
|
||
4 years ago
|
},
|
||
|
{
|
||
6 years ago
|
eventKey: 'transactionSubmitted',
|
||
|
hash: '0xa',
|
||
|
id: 1,
|
||
|
timestamp: 2,
|
||
|
value: '0x1',
|
||
4 years ago
|
},
|
||
|
{
|
||
6 years ago
|
eventKey: 'transactionResubmitted',
|
||
4 years ago
|
hash:
|
||
|
'0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
|
||
6 years ago
|
id: 2,
|
||
|
timestamp: 3,
|
||
|
value: '0x1',
|
||
4 years ago
|
},
|
||
|
{
|
||
6 years ago
|
eventKey: 'transactionCancelAttempted',
|
||
4 years ago
|
hash:
|
||
|
'0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
|
||
6 years ago
|
id: 3,
|
||
|
timestamp: 4,
|
||
|
value: '0x1',
|
||
|
},
|
||
4 years ago
|
];
|
||
6 years ago
|
|
||
|
const wrapper = shallow(
|
||
|
<TransactionActivityLog
|
||
|
activities={activities}
|
||
|
className="test-class"
|
||
|
inlineRetryIndex={2}
|
||
|
inlineCancelIndex={3}
|
||
|
nativeCurrency="ETH"
|
||
4 years ago
|
onCancel={() => undefined}
|
||
|
onRetry={() => undefined}
|
||
6 years ago
|
primaryTransactionStatus="pending"
|
||
5 years ago
|
isEarliestNonce
|
||
6 years ago
|
/>,
|
||
4 years ago
|
{ context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } },
|
||
4 years ago
|
);
|
||
6 years ago
|
|
||
4 years ago
|
expect(wrapper.hasClass('transaction-activity-log')).toStrictEqual(true);
|
||
|
expect(wrapper.hasClass('test-class')).toStrictEqual(true);
|
||
|
expect(wrapper.find('.transaction-activity-log__action-link')).toHaveLength(
|
||
4 years ago
|
2,
|
||
4 years ago
|
);
|
||
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('should not render inline retry and cancel buttons for newer pending transactions', () => {
|
||
5 years ago
|
const activities = [
|
||
|
{
|
||
|
eventKey: 'transactionCreated',
|
||
|
hash: '0xa',
|
||
|
id: 1,
|
||
|
timestamp: 1,
|
||
|
value: '0x1',
|
||
4 years ago
|
},
|
||
|
{
|
||
5 years ago
|
eventKey: 'transactionSubmitted',
|
||
|
hash: '0xa',
|
||
|
id: 1,
|
||
|
timestamp: 2,
|
||
|
value: '0x1',
|
||
4 years ago
|
},
|
||
|
{
|
||
5 years ago
|
eventKey: 'transactionResubmitted',
|
||
4 years ago
|
hash:
|
||
|
'0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
|
||
5 years ago
|
id: 2,
|
||
|
timestamp: 3,
|
||
|
value: '0x1',
|
||
4 years ago
|
},
|
||
|
{
|
||
5 years ago
|
eventKey: 'transactionCancelAttempted',
|
||
4 years ago
|
hash:
|
||
|
'0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
|
||
5 years ago
|
id: 3,
|
||
|
timestamp: 4,
|
||
|
value: '0x1',
|
||
|
},
|
||
4 years ago
|
];
|
||
5 years ago
|
|
||
|
const wrapper = shallow(
|
||
|
<TransactionActivityLog
|
||
|
activities={activities}
|
||
|
className="test-class"
|
||
|
inlineRetryIndex={2}
|
||
|
inlineCancelIndex={3}
|
||
|
nativeCurrency="ETH"
|
||
4 years ago
|
onCancel={() => undefined}
|
||
|
onRetry={() => undefined}
|
||
5 years ago
|
primaryTransactionStatus="pending"
|
||
|
isEarliestNonce={false}
|
||
|
/>,
|
||
4 years ago
|
{ context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } },
|
||
4 years ago
|
);
|
||
5 years ago
|
|
||
4 years ago
|
expect(wrapper.hasClass('transaction-activity-log')).toStrictEqual(true);
|
||
|
expect(wrapper.hasClass('test-class')).toStrictEqual(true);
|
||
|
expect(wrapper.find('.transaction-activity-log__action-link')).toHaveLength(
|
||
4 years ago
|
0,
|
||
4 years ago
|
);
|
||
|
});
|
||
|
});
|