diff --git a/Libraries/Components/TextInput/__tests__/TextInput-test.js b/Libraries/Components/TextInput/__tests__/TextInput-test.js index 5d912d78aef0b3..fb60e30e671053 100644 --- a/Libraries/Components/TextInput/__tests__/TextInput-test.js +++ b/Libraries/Components/TextInput/__tests__/TextInput-test.js @@ -102,15 +102,10 @@ describe('TextInput tests', () => { TextInput.State.focusTextInput(textInputRef.current); expect(textInputRef.current.isFocused()).toBe(true); expect(TextInput.State.currentlyFocusedInput()).toBe(textInputRef.current); - // This function is currently deprecated and will be removed in the future - expect(TextInput.State.currentlyFocusedField()).toBe( - ReactNative.findNodeHandle(textInputRef.current), - ); + TextInput.State.blurTextInput(textInputRef.current); expect(textInputRef.current.isFocused()).toBe(false); expect(TextInput.State.currentlyFocusedInput()).toBe(null); - // This function is currently deprecated and will be removed in the future - expect(TextInput.State.currentlyFocusedField()).toBe(null); }); it('should unfocus when other TextInput is focused', () => { @@ -144,24 +139,17 @@ describe('TextInput tests', () => { expect(textInputRe1.current.isFocused()).toBe(false); expect(textInputRe2.current.isFocused()).toBe(false); - const inputTag1 = ReactNative.findNodeHandle(textInputRe1.current); - const inputTag2 = ReactNative.findNodeHandle(textInputRe2.current); - TextInput.State.focusTextInput(textInputRe1.current); expect(textInputRe1.current.isFocused()).toBe(true); expect(textInputRe2.current.isFocused()).toBe(false); expect(TextInput.State.currentlyFocusedInput()).toBe(textInputRe1.current); - // This function is currently deprecated and will be removed in the future - expect(TextInput.State.currentlyFocusedField()).toBe(inputTag1); TextInput.State.focusTextInput(textInputRe2.current); expect(textInputRe1.current.isFocused()).toBe(false); expect(textInputRe2.current.isFocused()).toBe(true); expect(TextInput.State.currentlyFocusedInput()).toBe(textInputRe2.current); - // This function is currently deprecated and will be removed in the future - expect(TextInput.State.currentlyFocusedField()).toBe(inputTag2); }); it('should render as expected', () => { diff --git a/Libraries/Core/Timers/__tests__/JSTimers-test.js b/Libraries/Core/Timers/__tests__/JSTimers-test.js index 2df2001c7e3dae..d5f2dabf8f90f7 100644 --- a/Libraries/Core/Timers/__tests__/JSTimers-test.js +++ b/Libraries/Core/Timers/__tests__/JSTimers-test.js @@ -28,7 +28,7 @@ const JSTimers = require('../JSTimers'); describe('JSTimers', function () { beforeEach(function () { - jest.spyOn(console, 'warn'); + jest.spyOn(console, 'warn').mockReturnValue(undefined); global.setTimeout = JSTimers.setTimeout; }); diff --git a/Libraries/Image/__tests__/AssetUtils-test.js b/Libraries/Image/__tests__/AssetUtils-test.js index a5315293b9c304..f1cbe77e535408 100644 --- a/Libraries/Image/__tests__/AssetUtils-test.js +++ b/Libraries/Image/__tests__/AssetUtils-test.js @@ -17,7 +17,7 @@ describe('AssetUtils', () => { }); it('should return empty string and warn once if no cacheBreaker set (DEV)', () => { - const mockWarn = jest.spyOn(console, 'warn'); + const mockWarn = jest.spyOn(console, 'warn').mockReturnValue(undefined); global.__DEV__ = true; expect(getUrlCacheBreaker()).toEqual(''); expect(getUrlCacheBreaker()).toEqual(''); diff --git a/Libraries/Lists/__tests__/VirtualizedList-test.js b/Libraries/Lists/__tests__/VirtualizedList-test.js index 6fd9d915f47989..b2093ce07c1b10 100644 --- a/Libraries/Lists/__tests__/VirtualizedList-test.js +++ b/Libraries/Lists/__tests__/VirtualizedList-test.js @@ -362,7 +362,7 @@ describe('VirtualizedList', () => { const layout = {width: 300, height: 600}; let data = Array(20) .fill() - .map((_, key) => ({key: String(key)})); + .map((_, index) => ({key: `key-${index}`})); const onEndReached = jest.fn(); const props = { data, diff --git a/Libraries/LogBox/__tests__/LogBox-test.js b/Libraries/LogBox/__tests__/LogBox-test.js index 4c8144c7334c72..75b80cfb36a7ae 100644 --- a/Libraries/LogBox/__tests__/LogBox-test.js +++ b/Libraries/LogBox/__tests__/LogBox-test.js @@ -30,20 +30,20 @@ function mockFilterResult(returnValues) { } describe('LogBox', () => { - const {error, warn} = console; - let consoleError; - let consoleWarn; + const {error, log, warn} = console; beforeEach(() => { jest.resetModules(); - console.error = consoleError = jest.fn(); - console.warn = consoleWarn = jest.fn(); + console.error = jest.fn(); + console.log = jest.fn(); + console.warn = jest.fn(); console.disableYellowBox = false; }); afterEach(() => { LogBox.uninstall(); console.error = error; + console.log = log; console.warn = warn; }); @@ -329,6 +329,8 @@ describe('LogBox', () => { }); it('preserves decorations of console.error after installing/uninstalling', () => { + const consoleError = console.error; + LogBox.install(); const originalConsoleError = console.error; @@ -356,6 +358,8 @@ describe('LogBox', () => { }); it('preserves decorations of console.warn after installing/uninstalling', () => { + const consoleWarn = console.warn; + LogBox.install(); const originalConsoleWarn = console.warn; diff --git a/jest/mockNativeComponent.js b/jest/mockNativeComponent.js index e6080b7d1498e7..f6545e3bcffbfe 100644 --- a/jest/mockNativeComponent.js +++ b/jest/mockNativeComponent.js @@ -11,8 +11,12 @@ const React = require('react'); +let nativeTag = 1; + module.exports = viewName => { const Component = class extends React.Component { + _nativeTag = nativeTag++; + render() { return React.createElement(viewName, this.props, this.props.children); }