From 1d7c990424e1e6f72fd2732901d8e6c413823852 Mon Sep 17 00:00:00 2001 From: Miguel Jimenez Esun Date: Mon, 3 Jul 2017 07:44:38 -0700 Subject: [PATCH] Make a method used externaly (in a test) public Summary: The method is being used in a test, so if a private method name mangling happens, the name of the method changes and the test fails. Reviewed By: cpojer Differential Revision: D5347967 fbshipit-source-id: ee964c2876bcfea5253d2ce7f9f02d4dbeebeab3 --- Libraries/BatchedBridge/MessageQueue.js | 4 ++-- Libraries/BatchedBridge/__tests__/MessageQueue-test.js | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Libraries/BatchedBridge/MessageQueue.js b/Libraries/BatchedBridge/MessageQueue.js index 46bec14e3..27a7f5595 100644 --- a/Libraries/BatchedBridge/MessageQueue.js +++ b/Libraries/BatchedBridge/MessageQueue.js @@ -153,7 +153,7 @@ class MessageQueue { }; } - _getCallableModule(name: string) { + getCallableModule(name: string) { const getValue = this._lazyCallableModules[name]; return getValue ? getValue() : null; } @@ -252,7 +252,7 @@ class MessageQueue { if (this.__spy) { this.__spy({ type: TO_JS, module, method, args}); } - const moduleMethods = this._getCallableModule(module); + const moduleMethods = this.getCallableModule(module); invariant( !!moduleMethods, 'Module %s is not a registered callable module (calling %s)', diff --git a/Libraries/BatchedBridge/__tests__/MessageQueue-test.js b/Libraries/BatchedBridge/__tests__/MessageQueue-test.js index 38841a854..d9cd5a4e3 100644 --- a/Libraries/BatchedBridge/__tests__/MessageQueue-test.js +++ b/Libraries/BatchedBridge/__tests__/MessageQueue-test.js @@ -91,7 +91,8 @@ describe('MessageQueue', function() { it('should return lazily registered module', () => { const dummyModule = {}, name = 'modulesName'; queue.registerLazyCallableModule(name, () => dummyModule); - expect(queue._getCallableModule(name)).toEqual(dummyModule); + + expect(queue.getCallableModule(name)).toEqual(dummyModule); }); it('should not initialize lazily registered module before it was used for the first time', () => { @@ -105,8 +106,8 @@ describe('MessageQueue', function() { const dummyModule = {}, name = 'modulesName'; const factory = jest.fn(() => dummyModule); queue.registerLazyCallableModule(name, factory); - queue._getCallableModule(name); - queue._getCallableModule(name); + queue.getCallableModule(name); + queue.getCallableModule(name); expect(factory).toHaveBeenCalledTimes(1); }); });