mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
remove-unused-component (#9457)
This commit is contained in:
parent
97b49b7614
commit
e75bfc4dbc
@ -1 +0,0 @@
|
||||
export { default } from './transaction-action.component'
|
@ -1,121 +0,0 @@
|
||||
import assert from 'assert'
|
||||
import React from 'react'
|
||||
import { shallow } from 'enzyme'
|
||||
import sinon from 'sinon'
|
||||
import TransactionAction from '../transaction-action.component'
|
||||
|
||||
describe('TransactionAction Component', function () {
|
||||
const t = (key) => key
|
||||
|
||||
describe('Outgoing transaction', function () {
|
||||
beforeEach(function () {
|
||||
global.eth = {
|
||||
getCode: sinon.stub().callsFake((address) => {
|
||||
const code = address === 'approveAddress' ? 'contract' : '0x'
|
||||
return Promise.resolve(code)
|
||||
}),
|
||||
}
|
||||
})
|
||||
|
||||
it('should render Sent Ether', function () {
|
||||
const methodData = { data: {}, done: true, error: null }
|
||||
const transaction = {
|
||||
id: 1,
|
||||
status: 'confirmed',
|
||||
submittedTime: 1534045442919,
|
||||
time: 1534045440641,
|
||||
txParams: {
|
||||
from: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
|
||||
gas: '0x5208',
|
||||
gasPrice: '0x3b9aca00',
|
||||
nonce: '0x96',
|
||||
to: 'sentEtherAddress',
|
||||
value: '0x2386f26fc10000',
|
||||
},
|
||||
}
|
||||
|
||||
const wrapper = shallow((
|
||||
<TransactionAction
|
||||
methodData={methodData}
|
||||
transaction={transaction}
|
||||
className="transaction-action"
|
||||
/>
|
||||
), { context: { t } })
|
||||
|
||||
assert.equal(wrapper.find('.transaction-action').length, 1)
|
||||
wrapper.setState({ transactionAction: 'sentEther' })
|
||||
assert.equal(wrapper.text(), 'sentEther')
|
||||
assert.equal(wrapper.find('.transaction-action').props().title.trim(), 'sentEther')
|
||||
})
|
||||
|
||||
it('should render Approved', async function () {
|
||||
const methodData = {
|
||||
name: 'Approve',
|
||||
}
|
||||
const transaction = {
|
||||
id: 1,
|
||||
status: 'confirmed',
|
||||
submittedTime: 1534045442919,
|
||||
time: 1534045440641,
|
||||
txParams: {
|
||||
from: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
|
||||
gas: '0x5208',
|
||||
gasPrice: '0x3b9aca00',
|
||||
nonce: '0x96',
|
||||
to: 'approveAddress',
|
||||
value: '0x2386f26fc10000',
|
||||
data: '0x095ea7b300000000000000000000000050a9d56c2b8ba9a5c7f2c08c3d26e0499f23a7060000000000000000000000000000000000000000000000000000000000000003',
|
||||
},
|
||||
transactionCategory: 'contractInteraction',
|
||||
}
|
||||
|
||||
const wrapper = shallow(
|
||||
<TransactionAction
|
||||
methodData={methodData}
|
||||
transaction={transaction}
|
||||
className="test-class"
|
||||
/>,
|
||||
{ context: { t } },
|
||||
)
|
||||
|
||||
assert.ok(wrapper)
|
||||
assert.equal(wrapper.find('.transaction-action').length, 1)
|
||||
assert.equal(wrapper.find('.transaction-action').text().trim(), 'Approve')
|
||||
assert.equal(wrapper.find('.transaction-action').props().title.trim(), 'Approve')
|
||||
})
|
||||
|
||||
it('should render contractInteraction', async function () {
|
||||
const methodData = {}
|
||||
const transaction = {
|
||||
id: 1,
|
||||
status: 'confirmed',
|
||||
submittedTime: 1534045442919,
|
||||
time: 1534045440641,
|
||||
txParams: {
|
||||
from: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
|
||||
gas: '0x5208',
|
||||
gasPrice: '0x3b9aca00',
|
||||
nonce: '0x96',
|
||||
to: 'approveAddress',
|
||||
value: '0x2386f26fc10000',
|
||||
data: '0x095ea7b300000000000000000000000050a9d56c2b8ba9a5c7f2c08c3d26e0499f23a7060000000000000000000000000000000000000000000000000000000000000003',
|
||||
},
|
||||
transactionCategory: 'contractInteraction',
|
||||
}
|
||||
|
||||
const wrapper = shallow(
|
||||
<TransactionAction
|
||||
methodData={methodData}
|
||||
transaction={transaction}
|
||||
className="test-class"
|
||||
/>,
|
||||
{ context: { t } },
|
||||
)
|
||||
|
||||
assert.ok(wrapper)
|
||||
assert.equal(wrapper.find('.transaction-action').length, 1)
|
||||
assert.equal(wrapper.find('.transaction-action').text().trim(), 'contractInteraction')
|
||||
assert.equal(wrapper.find('.transaction-action').props().title.trim(), 'contractInteraction')
|
||||
})
|
||||
})
|
||||
})
|
@ -1,40 +0,0 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import classnames from 'classnames'
|
||||
import { getTransactionActionKey } from '../../../helpers/utils/transactions.util'
|
||||
import { camelCaseToCapitalize } from '../../../helpers/utils/common.util'
|
||||
|
||||
export default class TransactionAction extends PureComponent {
|
||||
static contextTypes = {
|
||||
t: PropTypes.func,
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
className: PropTypes.string,
|
||||
transaction: PropTypes.object,
|
||||
methodData: PropTypes.object,
|
||||
}
|
||||
|
||||
getTransactionAction () {
|
||||
const { transaction, methodData } = this.props
|
||||
const { name } = methodData
|
||||
|
||||
const actionKey = getTransactionActionKey(transaction)
|
||||
const action = actionKey && this.context.t(actionKey)
|
||||
const methodName = name && camelCaseToCapitalize(name)
|
||||
|
||||
return methodName || action || ''
|
||||
}
|
||||
|
||||
render () {
|
||||
const { className } = this.props
|
||||
|
||||
const action = this.getTransactionAction()
|
||||
|
||||
return (
|
||||
<div className={classnames('transaction-action', className)} title={action}>
|
||||
{ action }
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user