Skip to content

Commit

Permalink
✨ 4.4.5, close ant-design/ant-design#16710
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed May 26, 2019
1 parent 108b205 commit 6cf682a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "rc-input-number",
"version": "4.4.4",
"version": "4.4.5",
"description": "React input-number component",
"keywords": [
"react",
Expand Down
34 changes: 32 additions & 2 deletions tests/index.js
Expand Up @@ -6,14 +6,16 @@ import keyCode from 'rc-util/lib/KeyCode';
import expect from 'expect.js';
import InputNumber from '../src';
import React from 'react';
import { Simulate, findRenderedDOMComponentWithTag } from 'react-dom/test-utils';
import {
Simulate, findRenderedDOMComponentWithTag, scryRenderedDOMComponentsWithTag,
} from 'react-dom/test-utils';
import ReactDOM from 'react-dom';
import sinon from 'sinon';
import createReactClass from 'create-react-class';

const defaultValue = 98;

describe('inputNumber', () => {
describe('InputNumber', () => {
const container = document.createElement('div');
document.body.appendChild(container);
let onChangeFirstArgument;
Expand Down Expand Up @@ -1106,6 +1108,34 @@ describe('inputNumber', () => {
// be retained
expect(inputElement.value).to.be('401');
});

// https://github.com/ant-design/ant-design/issues/16710
it('should use correct precision when change it to 0', () => {
class Demo extends React.Component {
state = {
precision: 2,
};
onPrecisionChange = (precision) => {
this.setState({ precision });
};
render() {
const { precision } = this.state;
return (
<div>
<InputNumber onChange={this.onPrecisionChange} />
<InputNumber precision={precision} defaultValue={1.23} />
</div>
);
}
}
example = ReactDOM.render(<Demo />, container);
const [precisionInput, numberInput] = scryRenderedDOMComponentsWithTag(example, 'input');
expect(numberInput.value).to.be('1.23');
Simulate.focus(precisionInput);
Simulate.change(precisionInput, { target: { value: '0' } });
Simulate.blur(precisionInput);
expect(numberInput.value).to.be('1');
});
});

describe(`required prop`, () => {
Expand Down

0 comments on commit 6cf682a

Please sign in to comment.