Tests for DetailsStep (only bool dropdown)

This commit is contained in:
Jaco Greeff 2016-12-12 12:49:04 +01:00
parent c5c4e5e901
commit 563c8c75f9
2 changed files with 92 additions and 9 deletions

View File

@ -58,23 +58,23 @@ export default class DetailsStep extends Component {
<Form> <Form>
{ this.renderWarning() } { this.renderWarning() }
<AddressSelect <AddressSelect
label='from account'
hint='the account to transact with'
value={ fromAddress }
error={ fromAddressError }
accounts={ accounts } accounts={ accounts }
balances={ balances } balances={ balances }
onChange={ onFromAddressChange } /> error={ fromAddressError }
hint='the account to transact with'
label='from account'
onChange={ onFromAddressChange }
value={ fromAddress } />
{ this.renderFunctionSelect() } { this.renderFunctionSelect() }
{ this.renderParameters() } { this.renderParameters() }
<div className={ styles.columns }> <div className={ styles.columns }>
<div> <div>
<Input <Input
label='transaction value (in ETH)'
hint='the amount to send to with the transaction'
value={ amount }
error={ amountError } error={ amountError }
onSubmit={ onAmountChange } /> hint='the amount to send to with the transaction'
label='transaction value (in ETH)'
onSubmit={ onAmountChange }
value={ amount } />
</div> </div>
<div> <div>
<Checkbox <Checkbox

View File

@ -0,0 +1,83 @@
// Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
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(
<ContextProvider api={ {} } muiTheme={ muiTheme } store={ {} }>
<DetailsStep
{ ...props }
contract={ CONTRACT }
onAmountChange={ onAmountChange }
onClose={ onClose }
onFromAddressChange={ onFromAddressChange }
onFuncChange={ onFuncChange }
onGasEditClick={ onGasEditClick }
onValueChange={ onValueChange } />
</ContextProvider>
);
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);
});
});
});
});