1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 02:58:09 +01:00
metamask-extension/test/unit/components/pending-tx-test.js

68 lines
1.8 KiB
JavaScript
Raw Normal View History

const assert = require('assert')
const h = require('react-hyperscript')
2017-05-16 00:07:38 +02:00
const PendingTx = require('../../../ui/app/components/pending-tx')
2017-05-16 00:21:28 +02:00
const ethUtil = require('ethereumjs-util')
2017-11-02 18:28:41 +01:00
const { createMockStore } = require('redux-test-utils')
2017-11-26 01:37:12 +01:00
const { shallowWithStore } = require('../../lib/shallow-with-store')
2017-11-02 18:28:41 +01:00
const identities = { abc: {}, def: {} }
const mockState = {
metamask: {
accounts: { abc: {} },
identities,
conversionRate: 10,
selectedAddress: 'abc',
}
2017-11-02 18:28:41 +01:00
}
2017-11-02 18:28:41 +01:00
describe('PendingTx', function () {
const gasPrice = '0x4A817C800' // 20 Gwei
const txData = {
2017-05-28 20:18:07 +02:00
'id': 5021615666270214,
'time': 1494458763011,
'status': 'unapproved',
'metamaskNetworkId': '1494442339676',
'txParams': {
'from': '0xfdea65c8e26263f6d9a1b5de9555d2931a33b826',
'to': '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
'value': '0xde0b6b3a7640000',
gasPrice,
'gas': '0x7b0c',
},
2017-05-28 20:18:07 +02:00
'gasLimitSpecified': false,
'estimatedGas': '0x5208',
}
2017-11-02 18:28:41 +01:00
const newGasPrice = '0x77359400'
2017-11-02 18:28:41 +01:00
const computedBalances = {}
computedBalances[Object.keys(identities)[0]] = {
ethBalance: '0x00000000000000056bc75e2d63100000',
}
const props = {
txData,
computedBalances,
sendTransaction: (txMeta, event) => {
// Assert changes:
const result = ethUtil.addHexPrefix(txMeta.txParams.gasPrice)
assert.notEqual(result, gasPrice, 'gas price should change')
assert.equal(result, newGasPrice, 'gas price assigned.')
},
}
2017-11-02 18:28:41 +01:00
let pendingTxComponent
let store
let component
beforeEach(function () {
store = createMockStore(mockState)
component = shallowWithStore(h(PendingTx, props), store)
pendingTxComponent = component
})
2017-05-16 00:07:38 +02:00
2017-11-02 18:28:41 +01:00
it('should render correctly', function (done) {
assert.equal(pendingTxComponent.props().identities, identities)
done()
})
})