Fix React Component tests

This commit is contained in:
Shin'ya Ueoka 2019-04-30 09:03:01 +09:00
parent 4bac47249b
commit 808344eecf
15 changed files with 620 additions and 494 deletions

View file

@ -7,14 +7,9 @@ import PropTypes from 'prop-types';
class BlacklistForm extends React.Component {
render() {
let value = this.props.value;
if (!value) {
value = [];
}
return <div className='form-blacklist-form'>
{
value.map((url, index) => {
this.props.value.map((url, index) => {
return <div key={index} className='form-blacklist-form-row'>
<input data-index={index} type='text' name='url'
className='column-url' value={url}
@ -55,4 +50,8 @@ BlacklistForm.propTypes = {
onChange: PropTypes.func,
};
BlacklistForm.defaultProps = {
value: [],
};
export default BlacklistForm;

View file

@ -7,10 +7,6 @@ import keymaps from '../../keymaps';
class KeymapsForm extends React.Component {
render() {
let values = this.props.value;
if (!values) {
values = {};
}
return <div className='form-keymaps-form'>
{
keymaps.fields.map((group, index) => {
@ -19,7 +15,7 @@ class KeymapsForm extends React.Component {
group.map((field) => {
let name = field[0];
let label = field[1];
let value = values[name];
let value = this.props.value[name] || '';
return <Input
type='text' id={name} name={name} key={name}
label={label} value={value}
@ -50,4 +46,8 @@ KeymapsForm.propTypes = {
onChange: PropTypes.func,
};
KeymapsForm.defaultProps = {
value: {},
};
export default KeymapsForm;

View file

@ -8,9 +8,6 @@ class SearchForm extends React.Component {
render() {
let value = this.props.value;
if (!value) {
value = { default: '', engines: []};
}
if (!value.engines) {
value.engines = [];
}
@ -82,7 +79,10 @@ SearchForm.propTypes = {
engines: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)),
}),
onChange: PropTypes.func,
};
SearchForm.defaultProps = {
value: { default: '', engines: []},
};
export default SearchForm;