Skip to content

Commit

Permalink
updated test coverage and fixed change event
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinengle committed Aug 31, 2018
1 parent 13fd549 commit cb29b7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 1 addition & 5 deletions react/TextInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ export default class TextInput extends React.Component {
this.setState({value: this.props.value || this.props.defaultValue || ''})
}

handleChange = (ev) => {
this.setState({value: ev.target.value}, () => {
if (this.props.onChange) this.props.onChange(ev)
})
}
handleChange = ev => this.setState({value: ev.target.value}, () => this.props.onChange(ev))

handleLabelClick = () => this.input.focus()

Expand Down
5 changes: 5 additions & 0 deletions test/TextInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ describe('<TextInput />', () => {
expect(wrapper.find('.input__message').text()).to.equal('Test')
})

it('renders the provided default value', () => {
const wrapper = shallow(<TextInput defaultValue='T' message='Test' name='test' />)
expect(wrapper.find('.input__text').prop('value')).to.equal('T')
})

it('passes extra props down', () => {
const wrapper = shallow(<TextInput max={1} name='test' />)
expect(wrapper.find('.input__text').prop('name')).to.equal('test')
Expand Down

0 comments on commit cb29b7d

Please sign in to comment.