2017-05-11 02:26:51 +02:00
|
|
|
var assert = require('assert')
|
|
|
|
var PendingTx = require('../../../ui/app/components/pending-tx')
|
|
|
|
|
2017-05-11 23:29:44 +02:00
|
|
|
describe.only('PendingTx', function () {
|
2017-05-11 02:26:51 +02:00
|
|
|
let pendingTxComponent
|
|
|
|
|
|
|
|
const identities = {
|
|
|
|
'0xfdea65c8e26263f6d9a1b5de9555d2931a33b826': {
|
|
|
|
name: 'Main Account 1',
|
|
|
|
balance: '0x00000000000000056bc75e2d63100000',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
const gasPrice = '0x4A817C800' // 20 Gwei
|
|
|
|
const txData = {
|
|
|
|
'id':5021615666270214,
|
|
|
|
'time':1494458763011,
|
|
|
|
'status':'unapproved',
|
|
|
|
'metamaskNetworkId':'1494442339676',
|
|
|
|
'txParams':{
|
|
|
|
'from':'0xfdea65c8e26263f6d9a1b5de9555d2931a33b826',
|
|
|
|
'to':'0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
|
|
|
|
'value':'0xde0b6b3a7640000',
|
|
|
|
gasPrice,
|
|
|
|
'gas':'0x7b0c'},
|
|
|
|
'gasLimitSpecified':false,
|
|
|
|
'estimatedGas':'0x5208',
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
it('should use updated values when edited.', function (done) {
|
|
|
|
|
2017-05-12 00:28:33 +02:00
|
|
|
const newGasPrice = '0x451456'
|
|
|
|
|
2017-05-11 02:26:51 +02:00
|
|
|
const props = {
|
|
|
|
identities,
|
|
|
|
accounts: identities,
|
|
|
|
txData,
|
|
|
|
sendTransaction: (txMeta, event) => {
|
|
|
|
assert.notEqual(txMeta.txParams.gasPrice, gasPrice, 'gas price should change')
|
2017-05-12 00:28:33 +02:00
|
|
|
assert.equal(txMeta.txParams.gasPrice, newGasPrice, 'gas price assigned.')
|
2017-05-11 02:26:51 +02:00
|
|
|
done()
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
pendingTxComponent = new PendingTx(props)
|
|
|
|
|
|
|
|
const noop = () => {}
|
|
|
|
|
2017-05-11 23:29:44 +02:00
|
|
|
setTimeout(() => {
|
|
|
|
console.log('component mounted')
|
2017-05-11 02:26:51 +02:00
|
|
|
|
|
|
|
pendingTxComponent.gasPriceChanged(newGasPrice)
|
|
|
|
|
|
|
|
setTimeout(() => {
|
2017-05-11 23:29:44 +02:00
|
|
|
console.log('hitting submit')
|
2017-05-11 02:26:51 +02:00
|
|
|
pendingTxComponent.onSubmit({ preventDefault: noop })
|
|
|
|
}, 20)
|
2017-05-11 23:29:44 +02:00
|
|
|
}, 200)
|
2017-05-11 02:26:51 +02:00
|
|
|
|
2017-05-11 23:29:44 +02:00
|
|
|
console.log('calling render')
|
2017-05-11 02:26:51 +02:00
|
|
|
pendingTxComponent.props = props
|
2017-05-11 23:29:44 +02:00
|
|
|
pendingTxComponent.checkValidity = () => { return true }
|
2017-05-11 02:26:51 +02:00
|
|
|
pendingTxComponent.render()
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|