|
| 1 | +import React from 'react'; |
| 2 | +import KeyCode from 'rc-util/lib/KeyCode'; |
| 3 | +import { mount } from './util/wrapper'; |
| 4 | +import InputNumber from '../src'; |
| 5 | + |
| 6 | +describe.skip('InputNumber.Cursor', () => { |
| 7 | + // https://github.com/react-component/input-number/issues/235 |
| 8 | + // TODO: handle this |
| 9 | + describe('cursor position', () => { |
| 10 | + it('w', () => {}); |
| 11 | + // const setUpCursorTest = ( |
| 12 | + // initialValue, |
| 13 | + // changedValue, |
| 14 | + // keyCodeValue, |
| 15 | + // selectionStart, |
| 16 | + // selectionEnd, |
| 17 | + // ) => { |
| 18 | + // class Demo extends React.Component { |
| 19 | + // onChange = (value) => { |
| 20 | + // this.setState({ value }); |
| 21 | + // }; |
| 22 | + // render() { |
| 23 | + // return <InputNumber ref="inputNum" value={initialValue} onChange={this.onChange} />; |
| 24 | + // } |
| 25 | + // } |
| 26 | + // example = ReactDOM.render(<Demo />, container); |
| 27 | + // inputNumber = example.refs.inputNum; |
| 28 | + // inputNumber.input.selectionStart = selectionStart; |
| 29 | + // inputNumber.input.selectionEnd = selectionEnd || selectionStart; |
| 30 | + // inputElement = ReactDOM.findDOMNode(inputNumber.input); |
| 31 | + // Simulate.focus(inputElement); |
| 32 | + // Simulate.keyDown(inputElement, { keyCode: keyCodeValue }); |
| 33 | + // Simulate.change(inputElement, { target: { value: changedValue } }); |
| 34 | + // }; |
| 35 | + // it('should be maintained on delete with identical consecutive digits', () => { |
| 36 | + // setUpCursorTest(99999, '9999', keyCode.DELETE, 3); |
| 37 | + // expect(inputNumber.input.selectionStart).to.be(3); |
| 38 | + // }); |
| 39 | + // it('should be maintained on delete with unidentical consecutive digits', () => { |
| 40 | + // setUpCursorTest(12345, '1235', keyCode.DELETE, 3); |
| 41 | + // expect(inputNumber.input.selectionStart).to.be(3); |
| 42 | + // }); |
| 43 | + // it('should be one step earlier on backspace with identical consecutive digits', () => { |
| 44 | + // setUpCursorTest(99999, '9999', keyCode.BACKSPACE, 3); |
| 45 | + // expect(inputNumber.input.selectionStart).to.be(2); |
| 46 | + // }); |
| 47 | + // it('should be one step earlier on backspace with unidentical consecutive digits', () => { |
| 48 | + // setUpCursorTest(12345, '1245', keyCode.BACKSPACE, 3); |
| 49 | + // expect(inputNumber.input.selectionStart).to.be(2); |
| 50 | + // }); |
| 51 | + // it('should be at the start of selection on delete with identical consecutive digits', () => { |
| 52 | + // setUpCursorTest(99999, '999', keyCode.DELETE, 1, 3); |
| 53 | + // expect(inputNumber.input.selectionStart).to.be(1); |
| 54 | + // }); |
| 55 | + // it('should be at the start of selection on delete with unidentical consecutive digits', () => { |
| 56 | + // // eslint-disable-line |
| 57 | + // setUpCursorTest(12345, '145', keyCode.DELETE, 1, 3); |
| 58 | + // expect(inputNumber.input.selectionStart).to.be(1); |
| 59 | + // }); |
| 60 | + // it('should be at the start of selection on backspace with identical consecutive digits', () => { |
| 61 | + // // eslint-disable-line |
| 62 | + // setUpCursorTest(99999, '999', keyCode.BACKSPACE, 1, 3); |
| 63 | + // expect(inputNumber.input.selectionStart).to.be(1); |
| 64 | + // }); |
| 65 | + // it('should be at the start of selection on backspace with unidentical consecutive digits', () => { |
| 66 | + // // eslint-disable-line |
| 67 | + // setUpCursorTest(12345, '145', keyCode.BACKSPACE, 1, 3); |
| 68 | + // expect(inputNumber.input.selectionStart).to.be(1); |
| 69 | + // }); |
| 70 | + // it('should be one step later on new digit with identical consecutive digits', () => { |
| 71 | + // setUpCursorTest(99999, '999999', keyCode.NINE, 3); |
| 72 | + // expect(inputNumber.input.selectionStart).to.be(4); |
| 73 | + // }); |
| 74 | + // it('should be one step later on new digit with unidentical consecutive digits', () => { |
| 75 | + // setUpCursorTest(12345, '123945', keyCode.NINE, 3); |
| 76 | + // expect(inputNumber.input.selectionStart).to.be(4); |
| 77 | + // }); |
| 78 | + // it('should be one step later than the start of selection on new digit with identical consecutive digits', () => { |
| 79 | + // // eslint-disable-line |
| 80 | + // setUpCursorTest(99999, '9999', keyCode.NINE, 1, 3); |
| 81 | + // expect(inputNumber.input.selectionStart).to.be(2); |
| 82 | + // }); |
| 83 | + // it('should be one step later than the start of selection on new digit with unidentical consecutive digits', () => { |
| 84 | + // // eslint-disable-line |
| 85 | + // setUpCursorTest(12345, '1945', keyCode.NINE, 1, 3); |
| 86 | + // expect(inputNumber.input.selectionStart).to.be(2); |
| 87 | + // }); |
| 88 | + }); |
| 89 | + |
| 90 | + // https://github.com/ant-design/ant-design/issues/28366 |
| 91 | + // describe('cursor position when last string exists', () => { |
| 92 | + // // const setUpCursorTest = (initValue, prependValue) => { |
| 93 | + // // class Demo extends React.Component { |
| 94 | + // // state = { |
| 95 | + // // value: initValue, |
| 96 | + // // }; |
| 97 | + |
| 98 | + // // onChange = value => { |
| 99 | + // // this.setState({ value }); |
| 100 | + // // }; |
| 101 | + |
| 102 | + // // render() { |
| 103 | + // // return ( |
| 104 | + // // <InputNumber |
| 105 | + // // ref="inputNum" |
| 106 | + // // value={this.state.value} |
| 107 | + // // onChange={this.onChange} |
| 108 | + // // formatter={value => `$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} |
| 109 | + // // parser={value => value.replace(/\$\s?|(,*)/g, '')} |
| 110 | + // // /> |
| 111 | + // // ); |
| 112 | + // // } |
| 113 | + // // } |
| 114 | + // // example = ReactDOM.render(<Demo />, container); |
| 115 | + // // inputNumber = example.refs.inputNum; |
| 116 | + // // inputNumber.input.selectionStart = 0; |
| 117 | + // // inputNumber.input.selectionEnd = 0; |
| 118 | + // // inputElement = ReactDOM.findDOMNode(inputNumber.input); |
| 119 | + // // Simulate.focus(inputElement); |
| 120 | + // // for (let i = 0; i < prependValue.length; i += 1) { |
| 121 | + // // Simulate.keyDown(inputElement, { keyCode: keyCode.ONE }); |
| 122 | + // // } |
| 123 | + // // Simulate.change(inputElement, { target: { value: prependValue + initValue } }); |
| 124 | + // // }; |
| 125 | + |
| 126 | + // // it('shold fix caret position on case 1', () => { |
| 127 | + // // // '$ 1' |
| 128 | + // // setUpCursorTest('', '1'); |
| 129 | + // // expect(inputNumber.input.selectionStart).to.be(3); |
| 130 | + // // }); |
| 131 | + // // it('shold fix caret position on case 2', () => { |
| 132 | + // // // '$ 111' |
| 133 | + // // setUpCursorTest('', '111'); |
| 134 | + // // expect(inputNumber.input.selectionStart).to.be(5); |
| 135 | + // // }); |
| 136 | + // // it('shold fix caret position on case 3', () => { |
| 137 | + // // // '$ 111' |
| 138 | + // // setUpCursorTest('1', '11'); |
| 139 | + // // expect(inputNumber.input.selectionStart).to.be(4); |
| 140 | + // // }); |
| 141 | + // // it('shold fix caret position on case 4', () => { |
| 142 | + // // // '$ 123,456' |
| 143 | + // // setUpCursorTest('456', '123'); |
| 144 | + // // expect(inputNumber.input.selectionStart).to.be(6); |
| 145 | + // // }); |
| 146 | + // }); |
| 147 | +}); |
0 commit comments