From 563c8c75f94420d1d365738576fa63c81e901cab Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 12 Dec 2016 12:49:04 +0100 Subject: [PATCH] Tests for DetailsStep (only bool dropdown) --- .../DetailsStep/detailsStep.js | 18 ++-- .../DetailsStep/detailsStep.spec.js | 83 +++++++++++++++++++ 2 files changed, 92 insertions(+), 9 deletions(-) create mode 100644 js/src/modals/ExecuteContract/DetailsStep/detailsStep.spec.js diff --git a/js/src/modals/ExecuteContract/DetailsStep/detailsStep.js b/js/src/modals/ExecuteContract/DetailsStep/detailsStep.js index ae3c92e48..0e54e9ef4 100644 --- a/js/src/modals/ExecuteContract/DetailsStep/detailsStep.js +++ b/js/src/modals/ExecuteContract/DetailsStep/detailsStep.js @@ -58,23 +58,23 @@ export default class DetailsStep extends Component {
{ this.renderWarning() } + error={ fromAddressError } + hint='the account to transact with' + label='from account' + onChange={ onFromAddressChange } + value={ fromAddress } /> { this.renderFunctionSelect() } { this.renderParameters() }
+ hint='the amount to send to with the transaction' + label='transaction value (in ETH)' + onSubmit={ onAmountChange } + value={ amount } />
. + +import { mount } from 'enzyme'; +import React from 'react'; +import sinon from 'sinon'; + +import { ContextProvider, muiTheme } from '~/ui'; + +import DetailsStep from './'; + +import { CONTRACT } from '../executeContract.test.js'; + +let component; +let onAmountChange; +let onClose; +let onFromAddressChange; +let onFuncChange; +let onGasEditClick; +let onValueChange; + +function render (props) { + onAmountChange = sinon.stub(); + onClose = sinon.stub(); + onFromAddressChange = sinon.stub(); + onFuncChange = sinon.stub(); + onGasEditClick = sinon.stub(); + onValueChange = sinon.stub(); + + component = mount( + + + + ); + + return component; +} + +describe('modals/ExecuteContract/DetailsStep', () => { + it('renders', () => { + expect(render({ accounts: {}, values: [ true ], valuesError: [ null ] })).to.be.ok; + }); + + describe('parameter values', () => { + beforeEach(() => { + render({ + accounts: {}, + func: CONTRACT.functions[0], + values: [ false ], + valuesError: [ null ] + }); + }); + + describe('bool parameters', () => { + it('toggles from false to true', () => { + component.find('DropDownMenu').last().simulate('change', { target: { value: 'true' } }); + + expect(onValueChange).to.have.been.calledWith(null, 0, true); + }); + }); + }); +});