mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-31 17:53:50 +00:00
@@ -330,18 +330,27 @@ describe('components/TextInput', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('prop "onSelectionChange"', done => {
|
describe('prop "onSelectionChange"', () => {
|
||||||
const input = findNativeInput(
|
test('is called on select', done => {
|
||||||
mount(<TextInput defaultValue="12345" onSelectionChange={onSelectionChange} />)
|
const input = findNativeInput(
|
||||||
);
|
mount(<TextInput defaultValue="12345" onSelectionChange={onSelectionChange} />)
|
||||||
input.simulate('select', {
|
);
|
||||||
target: { selectionStart: 0, selectionEnd: 3 }
|
input.simulate('select', {
|
||||||
|
target: { selectionStart: 0, selectionEnd: 3 }
|
||||||
|
});
|
||||||
|
function onSelectionChange(e) {
|
||||||
|
expect(e.nativeEvent.selection.end).toEqual(3);
|
||||||
|
expect(e.nativeEvent.selection.start).toEqual(0);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('is called on change', () => {
|
||||||
|
const onSelectionChange = jest.fn();
|
||||||
|
const input = findNativeInput(mount(<TextInput onSelectionChange={onSelectionChange} />));
|
||||||
|
input.simulate('change');
|
||||||
|
expect(onSelectionChange).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
function onSelectionChange(e) {
|
|
||||||
expect(e.nativeEvent.selection.end).toEqual(3);
|
|
||||||
expect(e.nativeEvent.selection.start).toEqual(0);
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('prop "onSubmitEditing"', () => {
|
describe('prop "onSubmitEditing"', () => {
|
||||||
|
|||||||
@@ -282,6 +282,7 @@ class TextInput extends Component<*> {
|
|||||||
if (onChangeText) {
|
if (onChangeText) {
|
||||||
onChangeText(text);
|
onChangeText(text);
|
||||||
}
|
}
|
||||||
|
this._handleSelectionChange(e);
|
||||||
};
|
};
|
||||||
|
|
||||||
_handleFocus = e => {
|
_handleFocus = e => {
|
||||||
|
|||||||
Reference in New Issue
Block a user