Skip to content

Commit

Permalink
feat(NumberPicker): consider [。] as [.]
Browse files Browse the repository at this point in the history
  • Loading branch information
youluna committed Feb 28, 2019
1 parent ece8f04 commit 8369b4a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/number-picker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ class NumberPicker extends React.Component {
onChange(value, e) {
if (this.props.editable === true) {
value = value.trim();
// Compatible Chinese Input Method
value = value.replace('。', '.');
// ignore space
if (this.state.value === value) {
return;
Expand Down
14 changes: 14 additions & 0 deletions test/number-picker/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import NumberPicker from '../../src/number-picker/index';

Enzyme.configure({ adapter: new Adapter() });

/* global describe it */
describe('number-picker', () => {
describe('render', () => {
it('should accept defaultValue & value', () => {
Expand Down Expand Up @@ -386,6 +387,19 @@ describe('number-picker', () => {
done();
});

it('should consider [。] as [.]', done => {
const wrapper = mount(
<NumberPicker defaultValue={1.2} step={0.01} precision={3} />
);

wrapper
.find('input')
.simulate('change', { target: { value: '3。9' } });
assert(wrapper.find('input').prop('value') === 3.9);

done();
});

it('should support onCorrect', done => {
const onCorrect = sinon.spy();
const wrapper = mount(
Expand Down

0 comments on commit 8369b4a

Please sign in to comment.