Skip to content

Commit

Permalink
chore(*): update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
youluna authored and lakerswgq committed Oct 27, 2021
1 parent bf41b9b commit 153b07f
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions test/number-picker/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,47 @@ describe('number-picker', () => {
assert(wrapper1.find('button').at(1).prop("tabIndex") === -1);
});
it('should compare max or min the changes', () => {
let wrapper = mount(<NumberPicker max={10} defaultValue={10} />);
class App extends React.Component {
state = {
value: 10,
max: 8,
};

setMax = () => {
this.setState({
max: 5,
})
}

onChange = value => {
this.setState({
value,
});
};

render() {
return (
<div>
<button onClick={this.setMax}>setMax to 15</button>
<NumberPicker
value={this.state.value}
onChange={this.onChange}
max={this.state.max}
/>
</div>
);
}
}

let wrapper = mount(<App />);

wrapper.setProps({value: 20});
wrapper.find('input').simulate('blur');
assert(wrapper.find('input').prop('value') === 10);
assert(wrapper.find('input').prop('value') === 8);

wrapper.setProps({max: 15});
wrapper.find('input').simulate('click');
wrapper.find('button').at(0).simulate('click');
wrapper.find('input').simulate('blur');
assert(wrapper.find('input').prop('value') === 15);
assert(wrapper.find('input').prop('value') === 5);

});
});

Expand Down

0 comments on commit 153b07f

Please sign in to comment.