Skip to content

Commit

Permalink
Merge pull request facebook#91 from yungsters/master
Browse files Browse the repository at this point in the history
Fix `EventPluginRegistry` Unit Tests
  • Loading branch information
benjamn committed Jun 14, 2013
2 parents 80edd6c + 279792f commit 9fd9f71
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
23 changes: 23 additions & 0 deletions src/event/EventPluginRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* @typechecks
*/

"use strict";

var invariant = require('invariant');

/**
Expand Down Expand Up @@ -200,6 +202,27 @@ var EventPluginRegistry = {
}
}
return null;
},

/**
* Exposed for unit testing.
* @private
*/
_resetEventPlugins: function() {
EventPluginOrder = null;
for (var pluginName in namesToPlugins) {
if (namesToPlugins.hasOwnProperty(pluginName)) {
delete namesToPlugins[pluginName];
}
}
EventPluginRegistry.plugins.length = 0;
var registrationNames = EventPluginRegistry.registrationNames;
for (var registrationName in registrationNames) {
if (registrationNames.hasOwnProperty(registrationName)) {
delete registrationNames[registrationName];
}
}
EventPluginRegistry.registrationNamesKeys.length = 0;
}

};
Expand Down
2 changes: 1 addition & 1 deletion src/event/__tests__/EventPluginRegistry-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ describe('EventPluginRegistry', function() {
var createPlugin;

beforeEach(function() {
require('mock-modules').dumpCache();
EventPluginRegistry = require('EventPluginRegistry');
EventPluginRegistry._resetEventPlugins();

createPlugin = function(properties) {
return merge({extractEvents: function() {}}, properties);
Expand Down
9 changes: 7 additions & 2 deletions src/eventPlugins/__tests__/AnalyticsEventPlugin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,26 @@ var mocks = require('mocks');
describe('AnalyticsEventPlugin', function() {
var AnalyticsEventPluginFactory;
var EventPluginHub;
var EventPluginRegistry;
var React;
var ReactDefaultInjection;
var ReactEventEmitter;
var ReactEventTopLevelCallback;
var ReactTestUtils;

beforeEach(function() {
require('mock-modules').dumpCache();

AnalyticsEventPluginFactory = require('AnalyticsEventPluginFactory');
EventPluginHub = require('EventPluginHub');
EventPluginRegistry = require('EventPluginRegistry');
React = require('React');
ReactDefaultInjection = require('ReactDefaultInjection');
ReactEventEmitter = require('ReactEventEmitter');
ReactEventTopLevelCallback = require('ReactEventTopLevelCallback');
ReactTestUtils = require('ReactTestUtils');

EventPluginRegistry._resetEventPlugins();
ReactDefaultInjection.inject();

ReactEventEmitter.ensureListening(false, ReactEventTopLevelCallback);
});

Expand Down

0 comments on commit 9fd9f71

Please sign in to comment.