Remove _resetEventPlugins, use jest.resetModuleRegistry (#9111)
* Move EventPluginRegistry._resetEventPlugins to DEV This is not called during runtime at all and is only using in internal unit tests. Despite that, its currently being included in production builds. This change makes it so its only defined in DEV, which might even be too much (we can maybe inject it in our unit tests to avoid defining it at all in EventPluginRegistry) * Remove _resetEventsPlugin, use resetModuleRegistry
Brandon Dail committed
Mar 6, 2017 at 20:25 UTC
6ca2140c73a6e811ed6d5cbd9014640d59884ff3
2 files changed
+1
-40
src/renderers/shared/shared/event/EventPluginRegistry.js
-39
@@ -255,45 +255,6 @@ var EventPluginRegistry = {
255
recomputePluginOrdering();
256
}
257
},
258
-
259
- /**
260
- * Exposed for unit testing.
261
- * @private
262
- */
263
- _resetEventPlugins: function(): void {
264
- eventPluginOrder = null;
265
- for (var pluginName in namesToPlugins) {
266
- if (namesToPlugins.hasOwnProperty(pluginName)) {
267
- delete namesToPlugins[pluginName];
268
- }
269
- }
270
- EventPluginRegistry.plugins.length = 0;
271
-
272
- var eventNameDispatchConfigs = EventPluginRegistry.eventNameDispatchConfigs;
273
- for (var eventName in eventNameDispatchConfigs) {
274
- if (eventNameDispatchConfigs.hasOwnProperty(eventName)) {
275
- delete eventNameDispatchConfigs[eventName];
276
- }
277
- }
278
-
279
- var registrationNameModules = EventPluginRegistry.registrationNameModules;
280
- for (var registrationName in registrationNameModules) {
281
- if (registrationNameModules.hasOwnProperty(registrationName)) {
282
- delete registrationNameModules[registrationName];
283
- }
284
- }
285
-
286
- if (__DEV__) {
287
- var possibleRegistrationNames =
288
- EventPluginRegistry.possibleRegistrationNames;
289
- for (var lowerCasedName in possibleRegistrationNames) {
290
- if (possibleRegistrationNames.hasOwnProperty(lowerCasedName)) {
291
- delete possibleRegistrationNames[lowerCasedName];
292
- }
293
- }
294
- }
295
- },
296
-
258
};
259
260
module.exports = EventPluginRegistry;
src/renderers/shared/shared/event/__tests__/EventPluginRegistry-test.js
+1
-1
@@ -17,8 +17,8 @@ describe('EventPluginRegistry', () => {
17
var createPlugin;
18
19
beforeEach(() => {
20
+ jest.resetModuleRegistry();
21
EventPluginRegistry = require('EventPluginRegistry');
21
- EventPluginRegistry._resetEventPlugins();
22
23
createPlugin = function(properties) {
24
return Object.assign({extractEvents: function() {}}, properties);