From 69bb9e3c8cde351360f400d23fbc3232e7e2bec4 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Tue, 3 May 2016 16:46:51 +0100 Subject: [PATCH] Remove some mocks that are already packaged by InitializeJavaScriptAppEngine (#6642) (cherry picked from commit 760b1ef4c3b4706584f973bbcab273d86fa0a799) --- gulpfile.js | 2 -- .../native/ReactNativeDefaultInjection.js | 13 ++++++++----- src/renderers/native/ReactNativeEventEmitter.js | 2 +- .../__mocks__/InitializeJavaScriptAppEngine.js | 2 +- .../native/__mocks__/JSTimersExecution.js | 14 -------------- src/renderers/native/__mocks__/RCTEventEmitter.js | 6 ++++-- src/renderers/native/__mocks__/RCTLog.js | 14 -------------- 7 files changed, 14 insertions(+), 39 deletions(-) delete mode 100644 src/renderers/native/__mocks__/JSTimersExecution.js delete mode 100644 src/renderers/native/__mocks__/RCTLog.js diff --git a/gulpfile.js b/gulpfile.js index a51a094367..c3db76382c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -39,9 +39,7 @@ var whiteListNames = [ 'deepFreezeAndThrowOnMutationInDev', 'flattenStyle', 'InitializeJavaScriptAppEngine', - 'JSTimersExecution', 'RCTEventEmitter', - 'RCTLog', 'TextInputState', 'UIManager', 'View', diff --git a/src/renderers/native/ReactNativeDefaultInjection.js b/src/renderers/native/ReactNativeDefaultInjection.js index 21fc07ba88..be8a5625ea 100644 --- a/src/renderers/native/ReactNativeDefaultInjection.js +++ b/src/renderers/native/ReactNativeDefaultInjection.js @@ -15,11 +15,13 @@ * Make sure essential globals are available and are patched correctly. Please don't remove this * line. Bundles created by react-packager `require` it before executing any application code. This * ensures it exists in the dependency graph and can be `require`d. + * TODO: require this in packager, not in React #10932517 */ require('InitializeJavaScriptAppEngine'); var EventPluginHub = require('EventPluginHub'); var EventPluginUtils = require('EventPluginUtils'); +var RCTEventEmitter = require('RCTEventEmitter'); var ReactComponentEnvironment = require('ReactComponentEnvironment'); var ReactDefaultBatchingStrategy = require('ReactDefaultBatchingStrategy'); var ReactElement = require('ReactElement'); @@ -28,6 +30,7 @@ var ReactNativeBridgeEventPlugin = require('ReactNativeBridgeEventPlugin'); var ReactNativeComponent = require('ReactNativeComponent'); var ReactNativeComponentEnvironment = require('ReactNativeComponentEnvironment'); var ReactNativeComponentTree = require('ReactNativeComponentTree'); +var ReactNativeEventEmitter = require('ReactNativeEventEmitter'); var ReactNativeEventPluginOrder = require('ReactNativeEventPluginOrder'); var ReactNativeGlobalResponderHandler = require('ReactNativeGlobalResponderHandler'); var ReactNativeTextComponent = require('ReactNativeTextComponent'); @@ -38,12 +41,12 @@ var ResponderEventPlugin = require('ResponderEventPlugin'); var invariant = require('invariant'); -// Just to ensure this gets packaged, since its only caller is from Native. -require('RCTEventEmitter'); -require('RCTLog'); -require('JSTimersExecution'); - function inject() { + /** + * Register the event emitter with the native bridge + */ + RCTEventEmitter.register(ReactNativeEventEmitter); + /** * Inject module for resolving DOM hierarchy and plugin ordering. */ diff --git a/src/renderers/native/ReactNativeEventEmitter.js b/src/renderers/native/ReactNativeEventEmitter.js index 0018b63e55..699b092697 100644 --- a/src/renderers/native/ReactNativeEventEmitter.js +++ b/src/renderers/native/ReactNativeEventEmitter.js @@ -11,13 +11,13 @@ */ 'use strict'; +var EventConstants = require('EventConstants'); var EventPluginHub = require('EventPluginHub'); var EventPluginRegistry = require('EventPluginRegistry'); var ReactEventEmitterMixin = require('ReactEventEmitterMixin'); var ReactNativeComponentTree = require('ReactNativeComponentTree'); var ReactNativeTagHandles = require('ReactNativeTagHandles'); var ReactUpdates = require('ReactUpdates'); -var EventConstants = require('EventConstants'); var warning = require('warning'); diff --git a/src/renderers/native/__mocks__/InitializeJavaScriptAppEngine.js b/src/renderers/native/__mocks__/InitializeJavaScriptAppEngine.js index 3f4b4fdd0f..bc540c10d2 100644 --- a/src/renderers/native/__mocks__/InitializeJavaScriptAppEngine.js +++ b/src/renderers/native/__mocks__/InitializeJavaScriptAppEngine.js @@ -11,4 +11,4 @@ // Noop -// TODO: Move all initialization callers back into react-native +// TODO #10932517: Move all initialization callers back into react-native diff --git a/src/renderers/native/__mocks__/JSTimersExecution.js b/src/renderers/native/__mocks__/JSTimersExecution.js deleted file mode 100644 index 3f4b4fdd0f..0000000000 --- a/src/renderers/native/__mocks__/JSTimersExecution.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -'use strict'; - -// Noop - -// TODO: Move all initialization callers back into react-native diff --git a/src/renderers/native/__mocks__/RCTEventEmitter.js b/src/renderers/native/__mocks__/RCTEventEmitter.js index 3f4b4fdd0f..d6e66ad500 100644 --- a/src/renderers/native/__mocks__/RCTEventEmitter.js +++ b/src/renderers/native/__mocks__/RCTEventEmitter.js @@ -9,6 +9,8 @@ 'use strict'; -// Noop +var RCTEventEmitter = { + register: jest.fn(), +}; -// TODO: Move all initialization callers back into react-native +module.exports = RCTEventEmitter; diff --git a/src/renderers/native/__mocks__/RCTLog.js b/src/renderers/native/__mocks__/RCTLog.js deleted file mode 100644 index 3f4b4fdd0f..0000000000 --- a/src/renderers/native/__mocks__/RCTLog.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -'use strict'; - -// Noop - -// TODO: Move all initialization callers back into react-native