fix: texterea test

This commit is contained in:
Tom Xu 2020-11-20 11:01:10 +08:00
parent a9602b6d71
commit d4e8ac4499

View File

@ -176,10 +176,11 @@ describe('TextArea', () => {
it('set mouse cursor position', () => {
const defaultValue = '11111';
const valLength = defaultValue.length;
const wrapper = mount(<TextArea autoFocus defaultValue={defaultValue} />);
wrapper.instance().setSelectionRange(valLength, valLength);
expect(wrapper.instance().resizableTextArea.textArea.selectionStart).toEqual(5);
expect(wrapper.instance().resizableTextArea.textArea.selectionEnd).toEqual(5);
const ref = React.createRef();
mount(<TextArea autoFocus ref={ref} defaultValue={defaultValue} />);
ref.current.resizableTextArea.textArea.setSelectionRange(valLength, valLength);
expect(ref.current.resizableTextArea.textArea.selectionStart).toEqual(5);
expect(ref.current.resizableTextArea.textArea.selectionEnd).toEqual(5);
});
});