diff --git a/packages/react-native/Libraries/Components/TextInput/__tests__/TextInput-test.js b/packages/react-native/Libraries/Components/TextInput/__tests__/TextInput-test.js index af3faf5d5a4..763838352fa 100644 --- a/packages/react-native/Libraries/Components/TextInput/__tests__/TextInput-test.js +++ b/packages/react-native/Libraries/Components/TextInput/__tests__/TextInput-test.js @@ -7,6 +7,7 @@ * @format */ +const {create} = require('../../../../jest/renderer'); const ReactNative = require('../../../ReactNative/RendererProxy'); const { enter, @@ -24,7 +25,7 @@ describe('TextInput tests', () => { let onChangeListener; let onChangeTextListener; const initialValue = 'initialValue'; - beforeEach(() => { + beforeEach(async () => { inputRef = React.createRef(null); onChangeListener = jest.fn(); onChangeTextListener = jest.fn(); @@ -45,7 +46,7 @@ describe('TextInput tests', () => { /> ); } - const renderTree = ReactTestRenderer.create(); + const renderTree = await create(); input = renderTree.root.findByType(TextInput); }); it('has expected instance functions', () => { @@ -77,16 +78,16 @@ describe('TextInput tests', () => { }); }); - function createTextInput(extraProps) { + async function createTextInput(extraProps) { const textInputRef = React.createRef(null); - ReactTestRenderer.create( + await create( , ); return textInputRef; } - it('focus() should not do anything if the TextInput is not editable', () => { - const textInputRef = createTextInput({editable: false}); + it('focus() should not do anything if the TextInput is not editable', async () => { + const textInputRef = await createTextInput({editable: false}); textInputRef.current.currentProps = textInputRef.current.props; expect(textInputRef.current.isFocused()).toBe(false); @@ -94,8 +95,8 @@ describe('TextInput tests', () => { expect(textInputRef.current.isFocused()).toBe(false); }); - it('should have support for being focused and blurred', () => { - const textInputRef = createTextInput(); + it('should have support for being focused and blurred', async () => { + const textInputRef = await createTextInput(); expect(textInputRef.current.isFocused()).toBe(false); ReactNative.findNodeHandle = jest.fn().mockImplementation(ref => { @@ -122,11 +123,11 @@ describe('TextInput tests', () => { expect(TextInput.State.currentlyFocusedInput()).toBe(null); }); - it('should unfocus when other TextInput is focused', () => { + it('should unfocus when other TextInput is focused', async () => { const textInputRe1 = React.createRef(null); const textInputRe2 = React.createRef(null); - ReactTestRenderer.create( + await create( <> @@ -166,8 +167,8 @@ describe('TextInput tests', () => { expect(TextInput.State.currentlyFocusedInput()).toBe(textInputRe2.current); }); - it('should give precedence to `textContentType` when set', () => { - const instance = ReactTestRenderer.create( + it('should give precedence to `textContentType` when set', async () => { + const instance = await create( , ); @@ -213,8 +214,8 @@ describe('TextInput tests', () => { }); describe('TextInput', () => { - it('default render', () => { - const instance = ReactTestRenderer.create(); + it('default render', async () => { + const instance = await create(); expect(instance.toJSON()).toMatchInlineSnapshot(` { }); describe('TextInput compat with web', () => { - it('renders core props', () => { + it('renders core props', async () => { const props = { id: 'id', tabIndex: 0, testID: 'testID', }; - const instance = ReactTestRenderer.create(); + const instance = await create(); expect(instance.toJSON()).toMatchInlineSnapshot(` { `); }); - it('renders "aria-*" props', () => { + it('renders "aria-*" props', async () => { const props = { 'aria-activedescendant': 'activedescendant', 'aria-atomic': true, @@ -341,7 +342,7 @@ describe('TextInput compat with web', () => { 'aria-valuetext': '3', }; - const instance = ReactTestRenderer.create(); + const instance = await create(); expect(instance.toJSON()).toMatchInlineSnapshot(` { `); }); - it('renders styles', () => { + it('renders styles', async () => { const style = { display: 'flex', flex: 1, @@ -432,7 +433,7 @@ describe('TextInput compat with web', () => { verticalAlign: 'middle', }; - const instance = ReactTestRenderer.create(); + const instance = await create(); expect(instance.toJSON()).toMatchInlineSnapshot(`