diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-11-08 01:29:47 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-11-08 01:29:47 +0800 |
commit | 08867874ccea02dab9755ba6b0fc4221bb1dbf00 (patch) | |
tree | 5b2b893c4c00a14daa9724ba28ff7dc8f504ea10 /test/unit/components/pending-tx-test.js | |
parent | a89b682dec350218b2d753d6cfb196f965acdde2 (diff) | |
parent | acc973d543ac65f8db980c0007c248c509345411 (diff) | |
download | tangerine-wallet-browser-08867874ccea02dab9755ba6b0fc4221bb1dbf00.tar tangerine-wallet-browser-08867874ccea02dab9755ba6b0fc4221bb1dbf00.tar.gz tangerine-wallet-browser-08867874ccea02dab9755ba6b0fc4221bb1dbf00.tar.bz2 tangerine-wallet-browser-08867874ccea02dab9755ba6b0fc4221bb1dbf00.tar.lz tangerine-wallet-browser-08867874ccea02dab9755ba6b0fc4221bb1dbf00.tar.xz tangerine-wallet-browser-08867874ccea02dab9755ba6b0fc4221bb1dbf00.tar.zst tangerine-wallet-browser-08867874ccea02dab9755ba6b0fc4221bb1dbf00.zip |
Merge remote-tracking branch 'origin/uat' into mascara-first-screen
Diffstat (limited to 'test/unit/components/pending-tx-test.js')
-rw-r--r-- | test/unit/components/pending-tx-test.js | 92 |
1 files changed, 38 insertions, 54 deletions
diff --git a/test/unit/components/pending-tx-test.js b/test/unit/components/pending-tx-test.js index 20feba2a3..97cac3216 100644 --- a/test/unit/components/pending-tx-test.js +++ b/test/unit/components/pending-tx-test.js @@ -1,18 +1,22 @@ const assert = require('assert') -const additions = require('react-testutils-additions') const h = require('react-hyperscript') const PendingTx = require('../../../ui/app/components/pending-tx') -const ReactTestUtils = require('react-addons-test-utils') const ethUtil = require('ethereumjs-util') -describe('PendingTx', function () { - const identities = { - '0xfdea65c8e26263f6d9a1b5de9555d2931a33b826': { - name: 'Main Account 1', - balance: '0x00000000000000056bc75e2d63100000', - }, +const { createMockStore } = require('redux-test-utils') +const shallowWithStore = require('../../lib/shallow-with-store') + +const identities = { abc: {}, def: {} } +const mockState = { + metamask: { + accounts: { abc: {} }, + identities, + conversionRate: 10, + selectedAddress: 'abc', } +} +describe('PendingTx', function () { const gasPrice = '0x4A817C800' // 20 Gwei const txData = { 'id': 5021615666270214, @@ -29,55 +33,35 @@ describe('PendingTx', function () { 'gasLimitSpecified': false, 'estimatedGas': '0x5208', } + const newGasPrice = '0x77359400' + 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.') + }, + } - it('should use updated values when edited.', function (done) { - const renderer = ReactTestUtils.createRenderer() - const newGasPrice = '0x77359400' - - const computedBalances = {} - computedBalances[Object.keys(identities)[0]] = { - ethBalance: '0x00000000000000056bc75e2d63100000', - } - const props = { - identities, - accounts: identities, - 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.') - done() - }, - } - - const pendingTxComponent = h(PendingTx, props) - const component = additions.renderIntoDocument(pendingTxComponent) - renderer.render(pendingTxComponent) - const result = renderer.getRenderOutput() - assert.equal(result.type, 'div', 'should create a div') - - try { - const input = additions.find(component, '.cell.row input[type="number"]')[1] - ReactTestUtils.Simulate.change(input, { - target: { - value: 2, - checkValidity () { return true }, - }, - }) + let pendingTxComponent + let store + let component + beforeEach(function () { + store = createMockStore(mockState) + component = shallowWithStore(h(PendingTx, props), store) + pendingTxComponent = component + }) - const form = additions.find(component, 'form')[0] - form.checkValidity = () => true - form.getFormEl = () => { return { checkValidity () { return true } } } - ReactTestUtils.Simulate.submit(form, { preventDefault () {}, target: { checkValidity () { - return true - } } }) - } catch (e) { - console.log('WHAAAA') - console.error(e) - } + it('should render correctly', function (done) { + assert.equal(pendingTxComponent.props().identities, identities) + done() }) }) |