Skip to content

Commit

Permalink
add more test for pushable with not allowcross
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin-front committed Nov 6, 2017
1 parent 8437ce8 commit de05632
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/Range.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,34 @@ describe('Range', () => {
wrapper.setState({ value: [35, 40] });
expect(wrapper.instance().getSlider().state.bounds[0]).toBe(30);
expect(wrapper.instance().getSlider().state.bounds[1]).toBe(40);
wrapper.setState({ value: [30, 30] });
expect(wrapper.instance().getSlider().state.bounds[0]).toBe(30);
expect(wrapper.instance().getSlider().state.bounds[1]).toBe(40);
});

it('should keep pushable with pushable s defalutValue when not allowCross and setState', () => {
class CustomizedRange extends React.Component { // eslint-disable-line
constructor(props) {
super(props);
this.state = {
value: [20, 40],
};
}
getSlider() {
return this.refs.slider;
}
render() {
return <Range ref="slider" allowCross={false} value={this.state.value} pushable />;
}
}
const wrapper = mount(<CustomizedRange />);
expect(wrapper.instance().getSlider().state.bounds[0]).toBe(20);
expect(wrapper.instance().getSlider().state.bounds[1]).toBe(40);
wrapper.setState({ value: [40, 40] });
expect(wrapper.instance().getSlider().state.bounds[0]).toBe(39);
expect(wrapper.instance().getSlider().state.bounds[1]).toBe(40);
wrapper.setState({ value: [39, 38] });
expect(wrapper.instance().getSlider().state.bounds[0]).toBe(39);
expect(wrapper.instance().getSlider().state.bounds[1]).toBe(40);
});
});

0 comments on commit de05632

Please sign in to comment.