feature/default_network_editable
parent
8143f7725a
commit
084158f1a2
@ -1 +1 @@ |
||||
export { default } from './transaction-activity-log.component' |
||||
export { default } from './transaction-activity-log.container' |
||||
|
@ -0,0 +1,35 @@ |
||||
import React from 'react' |
||||
import assert from 'assert' |
||||
import { shallow } from 'enzyme' |
||||
import TransactionActivityLog from '../transaction-activity-log.component' |
||||
import Card from '../../card' |
||||
|
||||
describe('TransactionActivityLog Component', () => { |
||||
it('should render properly', () => { |
||||
const transaction = { |
||||
history: [], |
||||
id: 1, |
||||
status: 'confirmed', |
||||
txParams: { |
||||
from: '0x1', |
||||
gas: '0x5208', |
||||
gasPrice: '0x3b9aca00', |
||||
nonce: '0xa4', |
||||
to: '0x2', |
||||
value: '0x2386f26fc10000', |
||||
}, |
||||
} |
||||
|
||||
const wrapper = shallow( |
||||
<TransactionActivityLog |
||||
transaction={transaction} |
||||
className="test-class" |
||||
/>, |
||||
{ context: { t: (str1, str2) => str2 ? str1 + str2 : str1 } } |
||||
) |
||||
|
||||
assert.ok(wrapper.hasClass('transaction-activity-log')) |
||||
assert.ok(wrapper.hasClass('test-class')) |
||||
assert.equal(wrapper.find(Card).length, 1) |
||||
}) |
||||
}) |
@ -0,0 +1,27 @@ |
||||
import assert from 'assert' |
||||
import proxyquire from 'proxyquire' |
||||
|
||||
let mapStateToProps |
||||
|
||||
proxyquire('../transaction-activity-log.container.js', { |
||||
'react-redux': { |
||||
connect: ms => { |
||||
mapStateToProps = ms |
||||
return () => ({}) |
||||
}, |
||||
}, |
||||
}) |
||||
|
||||
describe('TransactionActivityLog container', () => { |
||||
describe('mapStateToProps()', () => { |
||||
it('should return the correct props', () => { |
||||
const mockState = { |
||||
metamask: { |
||||
conversionRate: 280.45, |
||||
}, |
||||
} |
||||
|
||||
assert.deepEqual(mapStateToProps(mockState), { conversionRate: 280.45 }) |
||||
}) |
||||
}) |
||||
}) |
@ -0,0 +1,208 @@ |
||||
import assert from 'assert' |
||||
import { getActivities } from '../transaction-activity-log.util' |
||||
|
||||
describe('getActivities', () => { |
||||
it('should return no activities for an empty history', () => { |
||||
const transaction = { |
||||
history: [], |
||||
id: 1, |
||||
status: 'confirmed', |
||||
txParams: { |
||||
from: '0x1', |
||||
gas: '0x5208', |
||||
gasPrice: '0x3b9aca00', |
||||
nonce: '0xa4', |
||||
to: '0x2', |
||||
value: '0x2386f26fc10000', |
||||
}, |
||||
} |
||||
|
||||
assert.deepEqual(getActivities(transaction), []) |
||||
}) |
||||
|
||||
it('should return activities for a transaction\'s history', () => { |
||||
const transaction = { |
||||
history: [ |
||||
{ |
||||
id: 5559712943815343, |
||||
loadingDefaults: true, |
||||
metamaskNetworkId: '3', |
||||
status: 'unapproved', |
||||
time: 1535507561452, |
||||
txParams: { |
||||
from: '0x1', |
||||
gas: '0x5208', |
||||
gasPrice: '0x3b9aca00', |
||||
nonce: '0xa4', |
||||
to: '0x2', |
||||
value: '0x2386f26fc10000', |
||||
}, |
||||
}, |
||||
[ |
||||
{ |
||||
op: 'replace', |
||||
path: '/loadingDefaults', |
||||
timestamp: 1535507561515, |
||||
value: false, |
||||
}, |
||||
{ |
||||
op: 'add', |
||||
path: '/gasPriceSpecified', |
||||
value: true, |
||||
}, |
||||
{ |
||||
op: 'add', |
||||
path: '/gasLimitSpecified', |
||||
value: true, |
||||
}, |
||||
{ |
||||
op: 'add', |
||||
path: '/estimatedGas', |
||||
value: '0x5208', |
||||
}, |
||||
], |
||||
[ |
||||
{ |
||||
note: '#newUnapprovedTransaction - adding the origin', |
||||
op: 'add', |
||||
path: '/origin', |
||||
timestamp: 1535507561516, |
||||
value: 'MetaMask', |
||||
}, |
||||
[], |
||||
], |
||||
[ |
||||
{ |
||||
note: 'confTx: user approved transaction', |
||||
op: 'replace', |
||||
path: '/txParams/gasPrice', |
||||
timestamp: 1535664571504, |
||||
value: '0x77359400', |
||||
}, |
||||
], |
||||
[ |
||||
{ |
||||
note: 'txStateManager: setting status to approved', |
||||
op: 'replace', |
||||
path: '/status', |
||||
timestamp: 1535507564302, |
||||
value: 'approved', |
||||
}, |
||||
], |
||||
[ |
||||
{ |
||||
note: 'transactions#approveTransaction', |
||||
op: 'add', |
||||
path: '/txParams/nonce', |
||||
timestamp: 1535507564439, |
||||
value: '0xa4', |
||||
}, |
||||
{ |
||||
op: 'add', |
||||
path: '/nonceDetails', |
||||
value: { |
||||
local: {}, |
||||
network: {}, |
||||
params: {}, |
||||
}, |
||||
}, |
||||
], |
||||
[ |
||||
{ |
||||
note: 'transactions#publishTransaction', |
||||
op: 'replace', |
||||
path: '/status', |
||||
timestamp: 1535507564518, |
||||
value: 'signed', |
||||
}, |
||||
{ |
||||
op: 'add', |
||||
path: '/rawTx', |
||||
value: '0xf86b81a4843b9aca008252089450a9d56c2b8ba9a5c7f2c08c3d26e0499f23a706872386f26fc10000802aa007b30119fc4fc5954fad727895b7e3ba80a78d197e95703cc603bcf017879151a01c50beda40ffaee541da9c05b9616247074f25f392800e0ad6c7a835d5366edf', |
||||
}, |
||||
], |
||||
[], |
||||
[ |
||||
{ |
||||
note: 'transactions#setTxHash', |
||||
op: 'add', |
||||
path: '/hash', |
||||
timestamp: 1535507564658, |
||||
value: '0x7acc4987b5c0dfa8d423798a8c561138259de1f98a62e3d52e7e83c0e0dd9fb7', |
||||
}, |
||||
], |
||||
[ |
||||
{ |
||||
note: 'txStateManager - add submitted time stamp', |
||||
op: 'add', |
||||
path: '/submittedTime', |
||||
timestamp: 1535507564660, |
||||
value: 1535507564660, |
||||
}, |
||||
], |
||||
[ |
||||
{ |
||||
note: 'txStateManager: setting status to submitted', |
||||
op: 'replace', |
||||
path: '/status', |
||||
timestamp: 1535507564665, |
||||
value: 'submitted', |
||||
}, |
||||
], |
||||
[ |
||||
{ |
||||
note: 'transactions/pending-tx-tracker#event: tx:block-update', |
||||
op: 'add', |
||||
path: '/firstRetryBlockNumber', |
||||
timestamp: 1535507575476, |
||||
value: '0x3bf624', |
||||
}, |
||||
], |
||||
[ |
||||
{ |
||||
note: 'txStateManager: setting status to confirmed', |
||||
op: 'replace', |
||||
path: '/status', |
||||
timestamp: 1535507615993, |
||||
value: 'confirmed', |
||||
}, |
||||
], |
||||
], |
||||
id: 1, |
||||
status: 'confirmed', |
||||
txParams: { |
||||
from: '0x1', |
||||
gas: '0x5208', |
||||
gasPrice: '0x3b9aca00', |
||||
nonce: '0xa4', |
||||
to: '0x2', |
||||
value: '0x2386f26fc10000', |
||||
}, |
||||
} |
||||
|
||||
const expectedResult = [ |
||||
{ |
||||
'eventKey': 'transactionCreated', |
||||
'timestamp': 1535507561452, |
||||
'value': '0x2386f26fc10000', |
||||
}, |
||||
{ |
||||
'eventKey': 'transactionUpdatedGas', |
||||
'timestamp': 1535664571504, |
||||
'value': '0x77359400', |
||||
}, |
||||
{ |
||||
'eventKey': 'transactionSubmitted', |
||||
'timestamp': 1535507564665, |
||||
'value': undefined, |
||||
}, |
||||
{ |
||||
'eventKey': 'transactionConfirmed', |
||||
'timestamp': 1535507615993, |
||||
'value': undefined, |
||||
}, |
||||
] |
||||
|
||||
assert.deepEqual(getActivities(transaction), expectedResult) |
||||
}) |
||||
}) |
@ -0,0 +1,11 @@ |
||||
import { connect } from 'react-redux' |
||||
import TransactionActivityLog from './transaction-activity-log.component' |
||||
import { conversionRateSelector } from '../../selectors' |
||||
|
||||
const mapStateToProps = state => { |
||||
return { |
||||
conversionRate: conversionRateSelector(state), |
||||
} |
||||
} |
||||
|
||||
export default connect(mapStateToProps)(TransactionActivityLog) |
Loading…
Reference in new issue