Merge remote-tracking branch 'origin/check-updates' into check-updates

This commit is contained in:
Jaco Greeff
2016-12-12 23:07:41 +01:00
13 changed files with 368 additions and 50 deletions

View File

@@ -46,26 +46,26 @@ export default class Select extends Component {
}
render () {
const { disabled, error, label, hint, value, children, className, onBlur, onChange, onKeyDown } = this.props;
const { children, className, disabled, error, hint, label, onBlur, onChange, onKeyDown, value } = this.props;
return (
<SelectField
className={ className }
autoComplete='off'
className={ className }
disabled={ disabled }
errorText={ error }
floatingLabelFixed
floatingLabelText={ label }
fullWidth
hintText={ hint }
name={ NAME_ID }
id={ NAME_ID }
underlineDisabledStyle={ UNDERLINE_DISABLED }
underlineStyle={ UNDERLINE_NORMAL }
value={ value }
name={ NAME_ID }
onBlur={ onBlur }
onChange={ onChange }
onKeyDown={ onKeyDown }>
onKeyDown={ onKeyDown }
underlineDisabledStyle={ UNDERLINE_DISABLED }
underlineStyle={ UNDERLINE_NORMAL }
value={ value }>
{ children }
</SelectField>
);

View File

@@ -289,9 +289,8 @@ export default class TypedInput extends Component {
return (
<MenuItem
key={ bool }
value={ bool }
label={ bool }
>
value={ bool }>
{ bool }
</MenuItem>
);
@@ -299,19 +298,23 @@ export default class TypedInput extends Component {
return (
<Select
label={ label }
hint={ hint }
value={ value ? 'true' : 'false' }
error={ error }
hint={ hint }
label={ label }
onChange={ this.onChangeBool }
>
value={
value
? 'true'
: 'false'
}>
{ boolitems }
</Select>
);
}
onChangeBool = (event, _index, value) => {
this.props.onChange(value === 'true');
// NOTE: event.target.value added for enzyme simulated event testing
this.props.onChange((value || event.target.value) === 'true');
}
onEthTypeChange = () => {

View File

@@ -0,0 +1,70 @@
// 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 { ABI_TYPES } from '~/util/abi';
import TypedInput from './';
let component;
let onChange;
function render (props) {
onChange = sinon.stub();
component = mount(
<ContextProvider api={ {} } muiTheme={ muiTheme } store={ {} }>
<TypedInput
{ ...props }
onChange={ onChange } />
</ContextProvider>
);
return component;
}
describe('ui/Form/TypedInput', () => {
describe('bool selection', () => {
beforeEach(() => {
render({ param: { type: ABI_TYPES.BOOL } });
});
it('renders', () => {
expect(component).to.be.ok;
});
it('calls onChange when value changes', () => {
component.find('DropDownMenu').simulate('change', { target: { value: 'true' } });
expect(onChange).to.have.been.called;
});
it("calls onChange(true) when value changes to 'true'", () => {
component.find('DropDownMenu').simulate('change', { target: { value: 'true' } });
expect(onChange).to.have.been.calledWith(true);
});
it("calls onChange(false) when value changes to 'false'", () => {
component.find('DropDownMenu').simulate('change', { target: { value: 'false' } });
expect(onChange).to.have.been.calledWith(false);
});
});
});

View File

@@ -19,6 +19,8 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import ContractIcon from 'material-ui/svg-icons/action/code';
import { createIdentityImg } from '~/api/util/identity';
import styles from './identityIcon.css';
class IdentityIcon extends Component {
@@ -29,12 +31,12 @@ class IdentityIcon extends Component {
static propTypes = {
address: PropTypes.string,
button: PropTypes.bool,
className: PropTypes.string,
center: PropTypes.bool,
padded: PropTypes.bool,
className: PropTypes.string,
inline: PropTypes.bool,
tiny: PropTypes.bool,
images: PropTypes.object.isRequired
images: PropTypes.object.isRequired,
padded: PropTypes.bool,
tiny: PropTypes.bool
}
state = {
@@ -75,7 +77,7 @@ class IdentityIcon extends Component {
}
this.setState({
iconsrc: api.util.createIdentityImg(_address, scale)
iconsrc: createIdentityImg(_address, scale)
});
}
@@ -105,16 +107,20 @@ class IdentityIcon extends Component {
return (
<ContractIcon
className={ classes }
style={ { width: size, height: size, background: '#eee' } } />
style={ {
width: size,
height: size,
background: '#eee'
} } />
);
}
return (
<img
className={ classes }
src={ iconsrc }
height={ size }
width={ size }
height={ size } />
src={ iconsrc } />
);
}
}