Skip to content

Commit

Permalink
Use ensureValueInRange & add precision to test.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukashambsch committed Oct 10, 2017
1 parent 310daf2 commit d8429a9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
8 changes: 1 addition & 7 deletions src/Range.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,7 @@ class Range extends React.Component {

if (bounds.some(v => utils.isValueOutOfRange(v, nextProps))) {
const newValues = value.map((v) => {
if (v < nextBounds[0]) {
v = nextBounds[0];
}
if (v > nextBounds[1]) {
v = nextBounds[1];
}
return v;
return utils.ensureValueInRange(v, nextProps);
});
this.props.onChange(newValues);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Range.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('Range', () => {

it('should only update bounds that are out of range', () => {
const props = { min: 0, max: 10000, value: [0.01, 10000], onChange: jest.fn() };
const range = mount(<Range {...props} />);
const range = mount(<Range {...props} step={0.1} />);
range.setProps({ min: 0, max: 500 });

expect(props.onChange).toHaveBeenCalledWith([0.01, 500]);
Expand Down

0 comments on commit d8429a9

Please sign in to comment.