Codemod old APIs away.

This commit is contained in:
cpojer
2015-10-28 22:15:30 -07:00
parent 9d25303d89
commit 2ecfc4f8fb
53 changed files with 105 additions and 140 deletions
@@ -23,7 +23,7 @@ describe('ReactCSSTransitionGroup', function() {
var container;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
ReactCSSTransitionGroup = require('ReactCSSTransitionGroup');
@@ -25,7 +25,7 @@ var reactComponentExpect;
describe('ReactContextValidator', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
@@ -11,7 +11,6 @@
/*global global:true*/
'use strict';
var mocks = require('mocks');
var React = require('React');
var ReactTestUtils = require('ReactTestUtils');
var reactComponentExpect = require('reactComponentExpect');
@@ -21,9 +20,9 @@ describe('autobinding', function() {
it('Holds reference to instance', function() {
var mouseDidEnter = mocks.getMockFunction();
var mouseDidLeave = mocks.getMockFunction();
var mouseDidClick = mocks.getMockFunction();
var mouseDidEnter = jest.genMockFn();
var mouseDidLeave = jest.genMockFn();
var mouseDidClick = jest.genMockFn();
var TestBindComponent = React.createClass({
getInitialState: function() {
@@ -96,7 +95,7 @@ describe('autobinding', function() {
});
it('works with mixins', function() {
var mouseDidClick = mocks.getMockFunction();
var mouseDidClick = jest.genMockFn();
var TestMixin = {
onClick: mouseDidClick,
@@ -11,7 +11,6 @@
/*global global:true*/
'use strict';
var mocks = require('mocks');
var React = require('React');
var ReactTestUtils = require('ReactTestUtils');
var reactComponentExpect = require('reactComponentExpect');
@@ -21,9 +20,9 @@ describe('autobind optout', function() {
it('should work with manual binding', function() {
var mouseDidEnter = mocks.getMockFunction();
var mouseDidLeave = mocks.getMockFunction();
var mouseDidClick = mocks.getMockFunction();
var mouseDidEnter = jest.genMockFn();
var mouseDidLeave = jest.genMockFn();
var mouseDidClick = jest.genMockFn();
var TestBindComponent = React.createClass({
autobind: false,
@@ -139,7 +138,7 @@ describe('autobind optout', function() {
});
it('works with mixins that have not opted out of autobinding', function() {
var mouseDidClick = mocks.getMockFunction();
var mouseDidClick = jest.genMockFn();
var TestMixin = {
onClick: mouseDidClick,
@@ -165,7 +164,7 @@ describe('autobind optout', function() {
});
it('works with mixins that have opted out of autobinding', function() {
var mouseDidClick = mocks.getMockFunction();
var mouseDidClick = jest.genMockFn();
var TestMixin = {
autobind: false,
@@ -11,8 +11,6 @@
'use strict';
var mocks = require('mocks');
var React;
var ReactDOM;
var ReactTestUtils;
@@ -46,7 +44,7 @@ describe('ReactClass-spec', function() {
});
it('should copy prop types onto the Constructor', function() {
var propValidator = mocks.getMockFunction();
var propValidator = jest.genMockFn();
var TestComponent = React.createClass({
propTypes: {
value: propValidator,
@@ -63,7 +61,7 @@ describe('ReactClass-spec', function() {
it('should warn on invalid prop types', function() {
var warn = console.error;
console.error = mocks.getMockFunction();
console.error = jest.genMockFn();
try {
React.createClass({
@@ -87,7 +85,7 @@ describe('ReactClass-spec', function() {
it('should warn on invalid context types', function() {
var warn = console.error;
console.error = mocks.getMockFunction();
console.error = jest.genMockFn();
try {
React.createClass({
displayName: 'Component',
@@ -110,7 +108,7 @@ describe('ReactClass-spec', function() {
it('should throw on invalid child context types', function() {
var warn = console.error;
console.error = mocks.getMockFunction();
console.error = jest.genMockFn();
try {
React.createClass({
displayName: 'Component',
@@ -11,8 +11,6 @@
'use strict';
var mocks = require('mocks');
var React;
var ReactTestUtils;
@@ -27,8 +25,8 @@ describe('ReactClass-mixin', function() {
beforeEach(function() {
React = require('React');
ReactTestUtils = require('ReactTestUtils');
mixinPropValidator = mocks.getMockFunction();
componentPropValidator = mocks.getMockFunction();
mixinPropValidator = jest.genMockFn();
componentPropValidator = jest.genMockFn();
var MixinA = {
propTypes: {
@@ -109,7 +107,7 @@ describe('ReactClass-mixin', function() {
});
it('should support merging propTypes and statics', function() {
var listener = mocks.getMockFunction();
var listener = jest.genMockFn();
var instance = <TestComponent listener={listener} />;
instance = ReactTestUtils.renderIntoDocument(instance);
@@ -124,7 +122,7 @@ describe('ReactClass-mixin', function() {
});
it('should support chaining delegate functions', function() {
var listener = mocks.getMockFunction();
var listener = jest.genMockFn();
var instance = <TestComponent listener={listener} />;
instance = ReactTestUtils.renderIntoDocument(instance);
@@ -137,7 +135,7 @@ describe('ReactClass-mixin', function() {
});
it('should chain functions regardless of spec property order', function() {
var listener = mocks.getMockFunction();
var listener = jest.genMockFn();
var instance = <TestComponentWithReverseSpec listener={listener} />;
instance = ReactTestUtils.renderIntoDocument(instance);
@@ -23,7 +23,7 @@ describe('ReactElement', function() {
var originalSymbol;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
// Delete the native Symbol if we have one to ensure we test the
// unpolyfilled environment.
@@ -339,7 +339,7 @@ describe('ReactElement', function() {
return OTHER_SYMBOL;
};
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
@@ -372,7 +372,7 @@ describe('comparing jsx vs .createFactory() vs .createElement()', function() {
var Child, mocks;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
mocks = require('mocks');
React = require('React');
ReactDOM = require('ReactDOM');
@@ -11,8 +11,6 @@
'use strict';
require('mock-modules');
var React;
var ReactDOM;
var ReactTestUtils;
@@ -22,7 +22,7 @@ describe('ReactElementValidator', function() {
var ComponentClass;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
@@ -764,7 +764,7 @@ describe('ReactPropTypes', function() {
describe('Custom validator', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
spyOn(console, 'error');
});
@@ -22,7 +22,7 @@ var emptyObject;
describe('cloneWithProps', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
ReactTestUtils = require('ReactTestUtils');
@@ -19,7 +19,7 @@ describe('ReactJSXElement', function() {
var Component;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
@@ -22,7 +22,7 @@ describe('ReactJSXElementValidator', function() {
var RequiredPropComponent;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactTestUtils = require('ReactTestUtils');
@@ -22,7 +22,7 @@ describe('ReactDOMProduction', function() {
oldProcess = process;
global.process = {env: {NODE_ENV: 'production'}};
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
});
@@ -12,7 +12,6 @@
'use strict';
var keyOf = require('keyOf');
var mocks = require('mocks');
var ReactMount = require('ReactMount');
var idToNode = {};
@@ -44,7 +43,7 @@ var recordIDAndReturnFalse = function(id, event) {
recordID(id);
return false;
};
var LISTENER = mocks.getMockFunction();
var LISTENER = jest.genMockFn();
var ON_CLICK_KEY = keyOf({onClick: null});
var ON_TOUCH_TAP_KEY = keyOf({onTouchTap: null});
var ON_CHANGE_KEY = keyOf({onChange: null});
@@ -76,7 +75,7 @@ function registerSimpleTestHandler() {
describe('ReactBrowserEventEmitter', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
LISTENER.mockClear();
EventPluginHub = require('EventPluginHub');
EventPluginRegistry = require('EventPluginRegistry');
@@ -306,7 +305,7 @@ describe('ReactBrowserEventEmitter', function() {
*/
it('should invoke handlers that were removed while bubbling', function() {
var handleParentClick = mocks.getMockFunction();
var handleParentClick = jest.genMockFn();
var handleChildClick = function(event) {
EventPluginHub.deleteAllListeners(getID(PARENT));
};
@@ -325,7 +324,7 @@ describe('ReactBrowserEventEmitter', function() {
});
it('should not invoke newly inserted handlers while bubbling', function() {
var handleParentClick = mocks.getMockFunction();
var handleParentClick = jest.genMockFn();
var handleChildClick = function(event) {
EventPluginHub.putListener(
getID(PARENT),
@@ -17,7 +17,7 @@ var ReactTestUtils;
describe('ReactEventIndependence', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
@@ -11,8 +11,6 @@
'use strict';
var mocks = require('mocks');
var EVENT_TARGET_PARAM = 1;
@@ -27,7 +25,7 @@ describe('ReactEventListener', function() {
var handleTopLevel;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
@@ -36,7 +34,7 @@ describe('ReactEventListener', function() {
ReactEventListener = require('ReactEventListener');
ReactTestUtils = require('ReactTestUtils');
handleTopLevel = mocks.getMockFunction();
handleTopLevel = jest.genMockFn();
ReactEventListener._handleTopLevel = handleTopLevel;
});
@@ -11,8 +11,6 @@
'use strict';
var mocks = require('mocks');
describe('ReactMount', function() {
var React = require('React');
var ReactDOM = require('ReactDOM');
@@ -81,8 +79,8 @@ describe('ReactMount', function() {
it('should unmount and remount if the key changes', function() {
var container = document.createElement('container');
var mockMount = mocks.getMockFunction();
var mockUnmount = mocks.getMockFunction();
var mockMount = jest.genMockFn();
var mockUnmount = jest.genMockFn();
var Component = React.createClass({
componentDidMount: mockMount,
@@ -199,9 +197,9 @@ describe('ReactMount', function() {
}
it('warns when using two copies of React before throwing', function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
var RD1 = require('ReactDOM');
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
var RD2 = require('ReactDOM');
var X = React.createClass({
@@ -11,7 +11,7 @@
'use strict';
require('mock-modules')
jest
.mock('ServerReactRootIndex');
var React;
@@ -33,7 +33,7 @@ var UNMOUNT_INVARIANT_MESSAGE =
describe('rendering React components at document', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
// Negative integer creator. So they won't get confused with
// the Client positive ids.
@@ -47,7 +47,7 @@ function isTagStackValid(stack) {
describe('ReactContextValidator', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
validateDOMNesting = require('validateDOMNesting');
});
@@ -21,7 +21,7 @@ var topLevelTypes;
describe('EnterLeaveEventPlugin', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
EnterLeaveEventPlugin = require('EnterLeaveEventPlugin');
EventConstants = require('EventConstants');
@@ -61,15 +61,13 @@ describe('SelectEventPlugin', function() {
});
it('should extract if an `onSelect` listener is present', function() {
var mocks = require('mocks');
var WithSelect = React.createClass({
render: function() {
return <input type="text" onSelect={this.props.onSelect} />;
},
});
var cb = mocks.getMockFunction();
var cb = jest.genMockFn();
var rendered = ReactTestUtils.renderIntoDocument(
<WithSelect onSelect={cb} />
@@ -12,14 +12,12 @@
'use strict';
var mocks = require('mocks');
describe('ReactDOMButton', function() {
var React;
var ReactDOM;
var ReactTestUtils;
var onClick = mocks.getMockFunction();
var onClick = jest.genMockFn();
function expectClickThru(button) {
onClick.mockClear();
@@ -13,7 +13,6 @@
var emptyFunction = require('emptyFunction');
var mocks = require('mocks');
describe('ReactDOMInput', function() {
var EventConstants;
@@ -23,7 +22,7 @@ describe('ReactDOMInput', function() {
var ReactTestUtils;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
EventConstants = require('EventConstants');
React = require('React');
ReactDOM = require('ReactDOM');
@@ -235,7 +234,7 @@ describe('ReactDOMInput', function() {
});
it('should support ReactLink', function() {
var link = new ReactLink('yolo', mocks.getMockFunction());
var link = new ReactLink('yolo', jest.genMockFn());
var instance = <input type="text" valueLink={link} />;
instance = ReactTestUtils.renderIntoDocument(instance);
@@ -252,7 +251,7 @@ describe('ReactDOMInput', function() {
});
it('should warn with value and no onChange handler', function() {
var link = new ReactLink('yolo', mocks.getMockFunction());
var link = new ReactLink('yolo', jest.genMockFn());
ReactTestUtils.renderIntoDocument(<input type="text" valueLink={link} />);
expect(console.error.argsForCall.length).toBe(1);
expect(console.error.argsForCall[0][0]).toContain(
@@ -260,7 +259,7 @@ describe('ReactDOMInput', function() {
);
ReactTestUtils.renderIntoDocument(
<input type="text" value="zoink" onChange={mocks.getMockFunction()} />
<input type="text" value="zoink" onChange={jest.genMockFn()} />
);
expect(console.error.argsForCall.length).toBe(1);
ReactTestUtils.renderIntoDocument(<input type="text" value="zoink" />);
@@ -292,7 +291,7 @@ describe('ReactDOMInput', function() {
it('should throw if both value and valueLink are provided', function() {
var node = document.createElement('div');
var link = new ReactLink('yolo', mocks.getMockFunction());
var link = new ReactLink('yolo', jest.genMockFn());
var instance = <input type="text" valueLink={link} />;
expect(() => ReactDOM.render(instance, node)).not.toThrow();
@@ -312,7 +311,7 @@ describe('ReactDOMInput', function() {
});
it('should support checkedLink', function() {
var link = new ReactLink(true, mocks.getMockFunction());
var link = new ReactLink(true, jest.genMockFn());
var instance = <input type="checkbox" checkedLink={link} />;
instance = ReactTestUtils.renderIntoDocument(instance);
@@ -330,7 +329,7 @@ describe('ReactDOMInput', function() {
it('should warn with checked and no onChange handler', function() {
var node = document.createElement('div');
var link = new ReactLink(true, mocks.getMockFunction());
var link = new ReactLink(true, jest.genMockFn());
ReactDOM.render(<input type="checkbox" checkedLink={link} />, node);
expect(console.error.argsForCall.length).toBe(1);
expect(console.error.argsForCall[0][0]).toContain(
@@ -341,7 +340,7 @@ describe('ReactDOMInput', function() {
<input
type="checkbox"
checked="false"
onChange={mocks.getMockFunction()}
onChange={jest.genMockFn()}
/>
);
expect(console.error.argsForCall.length).toBe(1);
@@ -369,7 +368,7 @@ describe('ReactDOMInput', function() {
it('should throw if both checked and checkedLink are provided', function() {
var node = document.createElement('div');
var link = new ReactLink(true, mocks.getMockFunction());
var link = new ReactLink(true, jest.genMockFn());
var instance = <input type="checkbox" checkedLink={link} />;
expect(() => ReactDOM.render(instance, node)).not.toThrow();
@@ -391,7 +390,7 @@ describe('ReactDOMInput', function() {
it('should throw if both checkedLink and valueLink are provided', function() {
var node = document.createElement('div');
var link = new ReactLink(true, mocks.getMockFunction());
var link = new ReactLink(true, jest.genMockFn());
var instance = <input type="checkbox" checkedLink={link} />;
expect(() => ReactDOM.render(instance, node)).not.toThrow();
@@ -12,8 +12,6 @@
'use strict';
var mocks = require('mocks');
describe('ReactDOMSelect', function() {
var React;
var ReactDOM;
@@ -350,7 +348,7 @@ describe('ReactDOMSelect', function() {
});
it('should support ReactLink', function() {
var link = new ReactLink('giraffe', mocks.getMockFunction());
var link = new ReactLink('giraffe', jest.genMockFn());
var stub =
<select valueLink={link}>
<option value="monkey">A monkey!</option>
@@ -12,7 +12,6 @@
'use strict';
var emptyFunction = require('emptyFunction');
var mocks = require('mocks');
describe('ReactDOMTextarea', function() {
var React;
@@ -238,7 +237,7 @@ describe('ReactDOMTextarea', function() {
});
it('should support ReactLink', function() {
var link = new ReactLink('yolo', mocks.getMockFunction());
var link = new ReactLink('yolo', jest.genMockFn());
var instance = <textarea valueLink={link} />;
spyOn(console, 'error');
@@ -11,8 +11,6 @@
'use strict';
var mocks = require('mocks');
var ExecutionEnvironment;
var React;
var ReactDOM;
@@ -25,7 +23,7 @@ var ID_ATTRIBUTE_NAME;
describe('ReactServerRendering', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
ReactMarkupChecksum = require('ReactMarkupChecksum');
@@ -74,7 +72,7 @@ describe('ReactServerRendering', function() {
it('should not register event listeners', function() {
var EventPluginHub = require('EventPluginHub');
var cb = mocks.getMockFunction();
var cb = jest.genMockFn();
ReactServerRendering.renderToString(
<span onClick={cb}>hello world</span>
@@ -288,7 +286,7 @@ describe('ReactServerRendering', function() {
it('should not register event listeners', function() {
var EventPluginHub = require('EventPluginHub');
var cb = mocks.getMockFunction();
var cb = jest.genMockFn();
ReactServerRendering.renderToString(
<span onClick={cb}>hello world</span>
@@ -15,7 +15,7 @@ describe('CSSProperty', function() {
var CSSProperty;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
CSSProperty = require('CSSProperty');
});
@@ -19,7 +19,7 @@ describe('CSSPropertyOperations', function() {
var CSSPropertyOperations;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
CSSPropertyOperations = require('CSSPropertyOperations');
});
@@ -18,7 +18,7 @@ describe('DOMPropertyOperations', function() {
var mocks;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
var ReactDefaultInjection = require('ReactDefaultInjection');
ReactDefaultInjection.inject();
@@ -270,7 +270,7 @@ describe('DOMPropertyOperations', function() {
});
it('should use mutation method where applicable', function() {
var foobarSetter = mocks.getMockFunction();
var foobarSetter = jest.genMockFn();
// inject foobar DOM property
DOMProperty.injection.injectDOMPropertyConfig({
Properties: {foobar: null},
@@ -17,7 +17,7 @@ describe('Danger', function() {
var Danger;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
Danger = require('Danger');
});
@@ -12,7 +12,6 @@
'use strict';
var assign = require('Object.assign');
var mocks = require('mocks');
describe('ReactDOMComponent', function() {
var React;
@@ -21,7 +20,7 @@ describe('ReactDOMComponent', function() {
var ReactDOMServer;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
ReactDOMServer = require('ReactDOMServer');
@@ -404,7 +403,7 @@ describe('ReactDOMComponent', function() {
var node = container.firstChild;
var nodeValue = ''; // node.value always returns undefined
var nodeValueSetter = mocks.getMockFunction();
var nodeValueSetter = jest.genMockFn();
Object.defineProperty(node, 'value', {
get: function() {
return nodeValue;
@@ -431,7 +430,7 @@ describe('ReactDOMComponent', function() {
var container = document.createElement('div');
var node = ReactDOM.render(<div />, container);
var setter = mocks.getMockFunction();
var setter = jest.genMockFn();
node.setAttribute = setter;
ReactDOM.render(<div dir={null} />, container);
@@ -659,8 +658,8 @@ describe('ReactDOMComponent', function() {
it('should execute custom event plugin listening behavior', function() {
var SimpleEventPlugin = require('SimpleEventPlugin');
SimpleEventPlugin.didPutListener = mocks.getMockFunction();
SimpleEventPlugin.willDeleteListener = mocks.getMockFunction();
SimpleEventPlugin.didPutListener = jest.genMockFn();
SimpleEventPlugin.willDeleteListener = jest.genMockFn();
var container = document.createElement('div');
ReactDOM.render(
@@ -678,8 +677,8 @@ describe('ReactDOMComponent', function() {
it('should handle null and missing properly with event hooks', function() {
var SimpleEventPlugin = require('SimpleEventPlugin');
SimpleEventPlugin.didPutListener = mocks.getMockFunction();
SimpleEventPlugin.willDeleteListener = mocks.getMockFunction();
SimpleEventPlugin.didPutListener = jest.genMockFn();
SimpleEventPlugin.willDeleteListener = jest.genMockFn();
var container = document.createElement('div');
ReactDOM.render(<div onClick={false} />, container);
@@ -858,8 +857,7 @@ describe('ReactDOMComponent', function() {
it('should warn about the `onScroll` issue when unsupported (IE8)', () => {
// Mock this here so we can mimic IE8 support. We require isEventSupported
// before React so it's pre-mocked before React qould require it.
require('mock-modules')
.dumpCache()
jest.resetModuleRegistry()
.mock('isEventSupported');
var isEventSupported = require('isEventSupported');
isEventSupported.mockReturnValueOnce(false);
@@ -11,7 +11,7 @@
'use strict';
require('mock-modules')
jest
.dontMock('EventPluginHub')
.mock('isEventSupported');
@@ -20,7 +20,7 @@ describe('EventPluginHub', function() {
var isEventSupported;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
EventPluginHub = require('EventPluginHub');
isEventSupported = require('isEventSupported');
isEventSupported.mockReturnValueOnce(false);
@@ -330,7 +330,7 @@ var siblings = {
describe('ResponderEventPlugin', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
EventConstants = require('EventConstants');
EventPluginHub = require('EventPluginHub');
@@ -258,7 +258,7 @@ describe('ReactComponent', function() {
});
it('fires the callback after a component is rendered', function() {
var callback = mocks.getMockFunction();
var callback = jest.genMockFn();
var container = document.createElement('div');
ReactDOM.render(<div />, container, callback);
expect(callback.mock.calls.length).toBe(1);
@@ -98,7 +98,7 @@ function getLifeCycleState(instance) {
*/
describe('ReactComponentLifeCycle', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
ReactTestUtils = require('ReactTestUtils');
@@ -27,7 +27,7 @@ var reactComponentExpect;
describe('ReactCompositeComponent', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
reactComponentExpect = require('reactComponentExpect');
React = require('React');
ReactDOM = require('ReactDOM');
@@ -11,8 +11,6 @@
'use strict';
var mocks = require('mocks');
var React;
var ReactDOM;
var ReactTestUtils;
@@ -92,7 +90,7 @@ describe('ReactCompositeComponentNestedState-state', function() {
var container = document.createElement('div');
document.body.appendChild(container);
var logger = mocks.getMockFunction();
var logger = jest.genMockFn();
void ReactDOM.render(
<ParentComponent logger={logger} />,
@@ -11,8 +11,6 @@
'use strict';
var mocks = require('mocks');
var React;
var ReactDOM;
@@ -132,7 +130,7 @@ describe('ReactCompositeComponent-state', function() {
var container = document.createElement('div');
document.body.appendChild(container);
var stateListener = mocks.getMockFunction();
var stateListener = jest.genMockFn();
var instance = ReactDOM.render(
<TestComponent stateListener={stateListener} />,
container,
@@ -20,7 +20,7 @@ var reactComponentExpect;
describe('ReactEmptyComponent', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
@@ -20,7 +20,7 @@ var ReactMount;
describe('ReactIdentity', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
ReactFragment = require('ReactFragment');
@@ -11,15 +11,13 @@
'use strict';
var mocks = require('mocks');
describe('ReactMultiChild', function() {
var React;
var ReactDOM;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
});
@@ -28,9 +26,9 @@ describe('ReactMultiChild', function() {
it('should update children when possible', function() {
var container = document.createElement('div');
var mockMount = mocks.getMockFunction();
var mockUpdate = mocks.getMockFunction();
var mockUnmount = mocks.getMockFunction();
var mockMount = jest.genMockFn();
var mockUpdate = jest.genMockFn();
var mockUnmount = jest.genMockFn();
var MockComponent = React.createClass({
componentDidMount: mockMount,
@@ -61,8 +59,8 @@ describe('ReactMultiChild', function() {
it('should replace children with different constructors', function() {
var container = document.createElement('div');
var mockMount = mocks.getMockFunction();
var mockUnmount = mocks.getMockFunction();
var mockMount = jest.genMockFn();
var mockUnmount = jest.genMockFn();
var MockComponent = React.createClass({
componentDidMount: mockMount,
@@ -89,8 +87,8 @@ describe('ReactMultiChild', function() {
it('should NOT replace children with different owners', function() {
var container = document.createElement('div');
var mockMount = mocks.getMockFunction();
var mockUnmount = mocks.getMockFunction();
var mockMount = jest.genMockFn();
var mockUnmount = jest.genMockFn();
var MockComponent = React.createClass({
componentDidMount: mockMount,
@@ -126,8 +124,8 @@ describe('ReactMultiChild', function() {
it('should replace children with different keys', function() {
var container = document.createElement('div');
var mockMount = mocks.getMockFunction();
var mockUnmount = mocks.getMockFunction();
var mockMount = jest.genMockFn();
var mockUnmount = jest.genMockFn();
var MockComponent = React.createClass({
componentDidMount: mockMount,
@@ -11,8 +11,6 @@
'use strict';
require('mock-modules');
var React = require('React');
var ReactDOM = require('ReactDOM');
var ReactInstanceMap = require('ReactInstanceMap');
@@ -237,7 +235,7 @@ function testPropsSequence(sequence) {
describe('ReactMultiChildReconcile', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
});
it('should reset internal state if removed then readded', function() {
@@ -11,8 +11,6 @@
'use strict';
require('mock-modules');
var React = require('React');
var ReactDOM = require('ReactDOM');
var ReactTestUtils = require('ReactTestUtils');
@@ -20,7 +20,7 @@ var TestComponentWithMixin;
describe('ReactStateSetters', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
TestComponent = React.createClass({
getInitialState: function() {
@@ -19,7 +19,7 @@ var TestComponent;
describe('refs-destruction', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
@@ -115,7 +115,7 @@ var expectClickLogsLengthToBe = function(instance, length) {
describe('reactiverefs', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
});
/**
@@ -158,7 +158,7 @@ describe('reactiverefs', function() {
*/
describe('ref swapping', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
});
var RefHopsAround = React.createClass({
@@ -134,7 +134,7 @@ var extractUniqueID = function(entity) {
describe('OrderedMap', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
OrderedMap = require('OrderedMap');
});
@@ -18,7 +18,7 @@ var Transaction;
var INIT_ERRORED = 'initErrored'; // Just a dummy value to check for.
describe('Transaction', function() {
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
Transaction = require('Transaction');
});
@@ -11,7 +11,7 @@
'use strict';
require('mock-modules')
jest
.dontMock('accumulateInto');
var accumulateInto;
@@ -16,7 +16,7 @@ describe('traverseAllChildren', function() {
var React;
var ReactFragment;
beforeEach(function() {
require('mock-modules').dumpCache();
jest.resetModuleRegistry();
traverseAllChildren = require('traverseAllChildren');
React = require('React');
ReactFragment = require('ReactFragment');
+1 -1
View File
@@ -24,7 +24,7 @@ describe('ReactDefaultPerf', function() {
beforeEach(function() {
var now = 0;
require('mock-modules').setMock('performanceNow', function() {
jest.setMock('performanceNow', function() {
return now++;
});
+1 -1
View File
@@ -75,7 +75,7 @@ describe('ReactTestUtils', function() {
});
it('should have shallow unmounting', function() {
var componentWillUnmount = mocks.getMockFunction();
var componentWillUnmount = jest.genMockFn();
var SomeComponent = React.createClass({
render: function() {