From 7e5d03553dc4924681f3df643ce11ac7777f00f3 Mon Sep 17 00:00:00 2001 From: cpojer Date: Tue, 26 Apr 2016 19:36:39 +0900 Subject: [PATCH] Update to Jest 12. Codemod to new Jest APIs. --- package.json | 2 +- .../__tests__/ReactErrorBoundaries-test.js | 4 ++-- .../classic/class/__tests__/ReactBind-test.js | 8 ++++---- .../class/__tests__/ReactBindOptout-test.js | 10 +++++----- .../classic/class/__tests__/ReactClass-test.js | 2 +- .../class/__tests__/ReactClassMixin-test.js | 10 +++++----- .../__tests__/ReactBrowserEventEmitter-test.js | 6 +++--- .../__tests__/ReactEventListener-test.js | 2 +- .../dom/client/__tests__/ReactMount-test.js | 4 ++-- .../__tests__/SelectEventPlugin-test.js | 2 +- .../__tests__/DisabledInputUtil-test.js | 2 +- .../wrappers/__tests__/ReactDOMInput-test.js | 18 +++++++++--------- .../wrappers/__tests__/ReactDOMSelect-test.js | 2 +- .../__tests__/ReactDOMTextarea-test.js | 2 +- .../__tests__/ReactServerRendering-test.js | 4 ++-- .../__tests__/DOMPropertyOperations-test.js | 2 +- .../shared/__tests__/ReactDOMComponent-test.js | 18 +++++++++--------- .../native/ReactNative/__mocks__/UIManager.js | 8 ++++---- .../ReactNativeAttributePayload-test.js | 12 ++++++------ .../event/__tests__/EventPluginHub-test.js | 2 +- .../__tests__/ReactComponent-test.js | 2 +- .../ReactCompositeComponentNestedState-test.js | 2 +- .../ReactCompositeComponentState-test.js | 2 +- .../__tests__/ReactMultiChild-test.js | 18 +++++++++--------- .../utils/__tests__/accumulateInto-test.js | 2 +- src/test/__tests__/ReactTestUtils-test.js | 2 +- 26 files changed, 74 insertions(+), 74 deletions(-) diff --git a/package.json b/package.json index c651733353281..19f70bd7ca18a 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "gulp-babel": "^6.0.0", "gulp-flatten": "^0.2.0", "gzip-js": "~0.3.2", - "jest-cli": "^0.9.0", + "jest-cli": "^12.0.2", "loose-envify": "^1.1.0", "object-assign": "^4.0.1", "platform": "^1.1.0", diff --git a/src/core/__tests__/ReactErrorBoundaries-test.js b/src/core/__tests__/ReactErrorBoundaries-test.js index 0ba37323d5522..7c8de2daf5948 100644 --- a/src/core/__tests__/ReactErrorBoundaries-test.js +++ b/src/core/__tests__/ReactErrorBoundaries-test.js @@ -50,7 +50,7 @@ describe('ReactErrorBoundaries', function() { var EventPluginHub = require('EventPluginHub'); var container = document.createElement('div'); - EventPluginHub.putListener = jest.genMockFn(); + EventPluginHub.putListener = jest.fn(); ReactDOM.render(, container); expect(EventPluginHub.putListener).not.toBeCalled(); }); @@ -120,7 +120,7 @@ describe('ReactErrorBoundaries', function() { var EventPluginHub = require('EventPluginHub'); var container = document.createElement('div'); - EventPluginHub.putListener = jest.genMockFn(); + EventPluginHub.putListener = jest.fn(); ReactDOM.render(, container); expect(EventPluginHub.putListener).toBeCalled(); }); diff --git a/src/isomorphic/classic/class/__tests__/ReactBind-test.js b/src/isomorphic/classic/class/__tests__/ReactBind-test.js index 63aa641a9c762..bbf9d0c7da41c 100644 --- a/src/isomorphic/classic/class/__tests__/ReactBind-test.js +++ b/src/isomorphic/classic/class/__tests__/ReactBind-test.js @@ -20,9 +20,9 @@ describe('autobinding', function() { it('Holds reference to instance', function() { - var mouseDidEnter = jest.genMockFn(); - var mouseDidLeave = jest.genMockFn(); - var mouseDidClick = jest.genMockFn(); + var mouseDidEnter = jest.fn(); + var mouseDidLeave = jest.fn(); + var mouseDidClick = jest.fn(); var TestBindComponent = React.createClass({ getInitialState: function() { @@ -95,7 +95,7 @@ describe('autobinding', function() { }); it('works with mixins', function() { - var mouseDidClick = jest.genMockFn(); + var mouseDidClick = jest.fn(); var TestMixin = { onClick: mouseDidClick, diff --git a/src/isomorphic/classic/class/__tests__/ReactBindOptout-test.js b/src/isomorphic/classic/class/__tests__/ReactBindOptout-test.js index 395e34577073e..54d3c11f5c970 100644 --- a/src/isomorphic/classic/class/__tests__/ReactBindOptout-test.js +++ b/src/isomorphic/classic/class/__tests__/ReactBindOptout-test.js @@ -20,9 +20,9 @@ describe('autobind optout', function() { it('should work with manual binding', function() { - var mouseDidEnter = jest.genMockFn(); - var mouseDidLeave = jest.genMockFn(); - var mouseDidClick = jest.genMockFn(); + var mouseDidEnter = jest.fn(); + var mouseDidLeave = jest.fn(); + var mouseDidClick = jest.fn(); var TestBindComponent = React.createClass({ autobind: false, @@ -138,7 +138,7 @@ describe('autobind optout', function() { }); it('works with mixins that have not opted out of autobinding', function() { - var mouseDidClick = jest.genMockFn(); + var mouseDidClick = jest.fn(); var TestMixin = { onClick: mouseDidClick, @@ -164,7 +164,7 @@ describe('autobind optout', function() { }); it('works with mixins that have opted out of autobinding', function() { - var mouseDidClick = jest.genMockFn(); + var mouseDidClick = jest.fn(); var TestMixin = { autobind: false, diff --git a/src/isomorphic/classic/class/__tests__/ReactClass-test.js b/src/isomorphic/classic/class/__tests__/ReactClass-test.js index 07a1e4bcb3a78..9a5587f7b7dd0 100644 --- a/src/isomorphic/classic/class/__tests__/ReactClass-test.js +++ b/src/isomorphic/classic/class/__tests__/ReactClass-test.js @@ -43,7 +43,7 @@ describe('ReactClass-spec', function() { }); it('should copy prop types onto the Constructor', function() { - var propValidator = jest.genMockFn(); + var propValidator = jest.fn(); var TestComponent = React.createClass({ propTypes: { value: propValidator, diff --git a/src/isomorphic/classic/class/__tests__/ReactClassMixin-test.js b/src/isomorphic/classic/class/__tests__/ReactClassMixin-test.js index a65c68ff071bb..f32af1e0460a2 100644 --- a/src/isomorphic/classic/class/__tests__/ReactClassMixin-test.js +++ b/src/isomorphic/classic/class/__tests__/ReactClassMixin-test.js @@ -25,8 +25,8 @@ describe('ReactClass-mixin', function() { beforeEach(function() { React = require('React'); ReactTestUtils = require('ReactTestUtils'); - mixinPropValidator = jest.genMockFn(); - componentPropValidator = jest.genMockFn(); + mixinPropValidator = jest.fn(); + componentPropValidator = jest.fn(); var MixinA = { propTypes: { @@ -107,7 +107,7 @@ describe('ReactClass-mixin', function() { }); it('should support merging propTypes and statics', function() { - var listener = jest.genMockFn(); + var listener = jest.fn(); var instance = ; instance = ReactTestUtils.renderIntoDocument(instance); @@ -122,7 +122,7 @@ describe('ReactClass-mixin', function() { }); it('should support chaining delegate functions', function() { - var listener = jest.genMockFn(); + var listener = jest.fn(); var instance = ; instance = ReactTestUtils.renderIntoDocument(instance); @@ -135,7 +135,7 @@ describe('ReactClass-mixin', function() { }); it('should chain functions regardless of spec property order', function() { - var listener = jest.genMockFn(); + var listener = jest.fn(); var instance = ; instance = ReactTestUtils.renderIntoDocument(instance); diff --git a/src/renderers/dom/client/__tests__/ReactBrowserEventEmitter-test.js b/src/renderers/dom/client/__tests__/ReactBrowserEventEmitter-test.js index 5dbf91c2cd853..9de6b2e8e2862 100644 --- a/src/renderers/dom/client/__tests__/ReactBrowserEventEmitter-test.js +++ b/src/renderers/dom/client/__tests__/ReactBrowserEventEmitter-test.js @@ -35,7 +35,7 @@ var recordIDAndReturnFalse = function(id, event) { recordID(id); return false; }; -var LISTENER = jest.genMockFn(); +var LISTENER = jest.fn(); var ON_CLICK_KEY = keyOf({onClick: null}); var ON_TOUCH_TAP_KEY = keyOf({onTouchTap: null}); var ON_CHANGE_KEY = keyOf({onChange: null}); @@ -284,7 +284,7 @@ describe('ReactBrowserEventEmitter', function() { */ it('should invoke handlers that were removed while bubbling', function() { - var handleParentClick = jest.genMockFn(); + var handleParentClick = jest.fn(); var handleChildClick = function(event) { EventPluginHub.deleteAllListeners(getInternal(PARENT)); }; @@ -303,7 +303,7 @@ describe('ReactBrowserEventEmitter', function() { }); it('should not invoke newly inserted handlers while bubbling', function() { - var handleParentClick = jest.genMockFn(); + var handleParentClick = jest.fn(); var handleChildClick = function(event) { EventPluginHub.putListener( getInternal(PARENT), diff --git a/src/renderers/dom/client/__tests__/ReactEventListener-test.js b/src/renderers/dom/client/__tests__/ReactEventListener-test.js index 49d4f195d5b90..049284f8f7054 100644 --- a/src/renderers/dom/client/__tests__/ReactEventListener-test.js +++ b/src/renderers/dom/client/__tests__/ReactEventListener-test.js @@ -30,7 +30,7 @@ describe('ReactEventListener', function() { ReactEventListener = require('ReactEventListener'); ReactTestUtils = require('ReactTestUtils'); - handleTopLevel = jest.genMockFn(); + handleTopLevel = jest.fn(); ReactEventListener._handleTopLevel = handleTopLevel; }); diff --git a/src/renderers/dom/client/__tests__/ReactMount-test.js b/src/renderers/dom/client/__tests__/ReactMount-test.js index 06b1c16415355..96ca4aef3336b 100644 --- a/src/renderers/dom/client/__tests__/ReactMount-test.js +++ b/src/renderers/dom/client/__tests__/ReactMount-test.js @@ -87,8 +87,8 @@ describe('ReactMount', function() { it('should unmount and remount if the key changes', function() { var container = document.createElement('container'); - var mockMount = jest.genMockFn(); - var mockUnmount = jest.genMockFn(); + var mockMount = jest.fn(); + var mockUnmount = jest.fn(); var Component = React.createClass({ componentDidMount: mockMount, diff --git a/src/renderers/dom/client/eventPlugins/__tests__/SelectEventPlugin-test.js b/src/renderers/dom/client/eventPlugins/__tests__/SelectEventPlugin-test.js index 0f032902d4829..46e21b96ce164 100644 --- a/src/renderers/dom/client/eventPlugins/__tests__/SelectEventPlugin-test.js +++ b/src/renderers/dom/client/eventPlugins/__tests__/SelectEventPlugin-test.js @@ -66,7 +66,7 @@ describe('SelectEventPlugin', function() { }, }); - var cb = jest.genMockFn(); + var cb = jest.fn(); var rendered = ReactTestUtils.renderIntoDocument( diff --git a/src/renderers/dom/client/wrappers/__tests__/DisabledInputUtil-test.js b/src/renderers/dom/client/wrappers/__tests__/DisabledInputUtil-test.js index 0e4c77d55653b..a99546ecc25ff 100644 --- a/src/renderers/dom/client/wrappers/__tests__/DisabledInputUtil-test.js +++ b/src/renderers/dom/client/wrappers/__tests__/DisabledInputUtil-test.js @@ -36,7 +36,7 @@ describe('DisabledInputUtils', function() { return element; } - var onClick = jest.genMockFn(); + var onClick = jest.fn(); elements.forEach(function(tagName) { diff --git a/src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js b/src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js index 7db938bfc5741..f7ff9328a6a00 100644 --- a/src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js +++ b/src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js @@ -245,7 +245,7 @@ describe('ReactDOMInput', function() { }); it('should support ReactLink', function() { - var link = new ReactLink('yolo', jest.genMockFn()); + var link = new ReactLink('yolo', jest.fn()); var instance = ; instance = ReactTestUtils.renderIntoDocument(instance); @@ -262,7 +262,7 @@ describe('ReactDOMInput', function() { }); it('should warn with value and no onChange handler', function() { - var link = new ReactLink('yolo', jest.genMockFn()); + var link = new ReactLink('yolo', jest.fn()); ReactTestUtils.renderIntoDocument(); expect(console.error.argsForCall.length).toBe(1); expect(console.error.argsForCall[0][0]).toContain( @@ -270,7 +270,7 @@ describe('ReactDOMInput', function() { ); ReactTestUtils.renderIntoDocument( - + ); expect(console.error.argsForCall.length).toBe(1); ReactTestUtils.renderIntoDocument(); @@ -302,7 +302,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', jest.genMockFn()); + var link = new ReactLink('yolo', jest.fn()); var instance = ; expect(() => ReactDOM.render(instance, node)).not.toThrow(); @@ -322,7 +322,7 @@ describe('ReactDOMInput', function() { }); it('should support checkedLink', function() { - var link = new ReactLink(true, jest.genMockFn()); + var link = new ReactLink(true, jest.fn()); var instance = ; instance = ReactTestUtils.renderIntoDocument(instance); @@ -340,7 +340,7 @@ describe('ReactDOMInput', function() { it('should warn with checked and no onChange handler', function() { var node = document.createElement('div'); - var link = new ReactLink(true, jest.genMockFn()); + var link = new ReactLink(true, jest.fn()); ReactDOM.render(, node); expect(console.error.argsForCall.length).toBe(1); expect(console.error.argsForCall[0][0]).toContain( @@ -351,7 +351,7 @@ describe('ReactDOMInput', function() { ); expect(console.error.argsForCall.length).toBe(1); @@ -379,7 +379,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, jest.genMockFn()); + var link = new ReactLink(true, jest.fn()); var instance = ; expect(() => ReactDOM.render(instance, node)).not.toThrow(); @@ -401,7 +401,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, jest.genMockFn()); + var link = new ReactLink(true, jest.fn()); var instance = ; expect(() => ReactDOM.render(instance, node)).not.toThrow(); diff --git a/src/renderers/dom/client/wrappers/__tests__/ReactDOMSelect-test.js b/src/renderers/dom/client/wrappers/__tests__/ReactDOMSelect-test.js index 0a3f53028314f..c4276c143f3c3 100644 --- a/src/renderers/dom/client/wrappers/__tests__/ReactDOMSelect-test.js +++ b/src/renderers/dom/client/wrappers/__tests__/ReactDOMSelect-test.js @@ -348,7 +348,7 @@ describe('ReactDOMSelect', function() { }); it('should support ReactLink', function() { - var link = new ReactLink('giraffe', jest.genMockFn()); + var link = new ReactLink('giraffe', jest.fn()); var stub =