| 2627 | |
| 2628 | describe('assigning the value attribute on controlled inputs', function () { |
| 2629 | function getTestInput() { |
| 2630 | return class extends React.Component { |
| 2631 | state = { |
| 2632 | value: this.props.value == null ? '' : this.props.value, |
| 2633 | }; |
| 2634 | onChange = event => { |
| 2635 | this.setState({value: event.target.value}); |
| 2636 | }; |
| 2637 | render() { |
| 2638 | const type = this.props.type; |
| 2639 | const value = this.state.value; |
| 2640 | |
| 2641 | return <input type={type} value={value} onChange={this.onChange} />; |
| 2642 | } |
| 2643 | }; |
| 2644 | } |
| 2645 | |
| 2646 | it('always sets the attribute when values change on text inputs', async () => { |
| 2647 | const Input = getTestInput(); |