From 9a00cecae436e4e300f49301b110bedaa14a3c91 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Thu, 19 Mar 2020 11:38:45 -0700 Subject: [PATCH] Fix mock for TextInput (#28332) Summary: This PR adds the `isFocused` method to the mock of the TextInput component. My understanding some of the latest changes on the TextInput to make it use a forwardRef change the way this method is mock giving an error when trying to use in on a mock. The change suggested here fixes the issue. ## Changelog [JavaScript] [Fixed] - Fix the mock for TextInput to support the `isFocused` method Pull Request resolved: https://github.com/facebook/react-native/pull/28332 Reviewed By: cpojer Differential Revision: D20538044 Pulled By: TheSavior fbshipit-source-id: be734af105ab62ffdf9ed4017bd70845e207f8cd --- jest/setup.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jest/setup.js b/jest/setup.js index 09bc4b3d2b64b6..d580959f8dcee1 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -89,10 +89,12 @@ jest mockComponent('../Libraries/Text/Text', MockNativeMethods), ) .mock('../Libraries/Components/TextInput/TextInput', () => - mockComponent( - '../Libraries/Components/TextInput/TextInput', - MockNativeMethods, - ), + mockComponent('../Libraries/Components/TextInput/TextInput', { + ...MockNativeMethods, + isFocused: jest.fn(), + clear: jest.fn(), + getNativeRef: jest.fn(), + }), ) .mock('../Libraries/Modal/Modal', () => mockComponent('../Libraries/Modal/Modal'),