From d8a0b9a662faccfbcca4cb021afed13b86532014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Fri, 11 Dec 2015 11:02:47 -0800 Subject: [PATCH 1/6] Upgrade to jest-cli@0.9 and use Jasmine2 --- package.json | 1 + scripts/jest/jest.d.ts | 1 + scripts/jest/test-framework-setup.js | 63 +++-- src/addons/__tests__/ReactFragment-test.js | 22 +- .../renderSubtreeIntoContainer-test.js | 2 +- src/addons/__tests__/update-test.js | 22 +- .../__tests__/ReactCSSTransitionGroup-test.js | 6 +- .../children/__tests__/ReactChildren-test.js | 26 +- .../__tests__/ReactContextValidator-test.js | 20 +- .../classic/class/__tests__/ReactBind-test.js | 6 +- .../class/__tests__/ReactBindOptout-test.js | 4 +- .../class/__tests__/ReactClass-test.js | 32 +-- .../class/__tests__/ReactClassMixin-test.js | 14 +- .../element/__tests__/ReactElement-test.js | 24 +- .../__tests__/ReactElementClone-test.js | 18 +- .../__tests__/ReactElementValidator-test.js | 86 +++---- .../types/__tests__/ReactPropTypes-test.js | 26 +- .../ReactCoffeeScriptClass-test.coffee | 30 +-- .../class/__tests__/ReactES6Class-test.js | 30 +-- .../__tests__/ReactTypeScriptClass-test.ts | 34 +-- .../element/__tests__/ReactJSXElement-test.js | 10 +- .../ReactJSXElementValidator-test.js | 64 ++--- .../dom/__tests__/ReactDOMProduction-test.js | 4 +- .../ReactBrowserEventEmitter-test.js | 10 +- .../dom/client/__tests__/ReactDOM-test.js | 2 +- .../dom/client/__tests__/ReactMount-test.js | 32 +-- .../__tests__/ReactMountDestruction-test.js | 8 +- .../__tests__/ReactRenderDocument-test.js | 8 +- .../dom/client/__tests__/findDOMNode-test.js | 4 +- .../__tests__/SyntheticEvent-test.js | 28 +-- .../wrappers/__tests__/ReactDOMInput-test.js | 78 +++--- .../wrappers/__tests__/ReactDOMOption-test.js | 8 +- .../wrappers/__tests__/ReactDOMSelect-test.js | 12 +- .../__tests__/ReactDOMTextarea-test.js | 24 +- .../__tests__/ReactServerRendering-test.js | 6 +- .../__tests__/CSSPropertyOperations-test.js | 26 +- .../__tests__/DOMPropertyOperations-test.js | 4 +- .../dom/shared/__tests__/Danger-test.js | 6 +- .../__tests__/ReactDOMComponent-test.js | 227 +++++++++--------- .../event/__tests__/EventPluginHub-test.js | 2 +- .../__tests__/EventPluginRegistry-test.js | 12 +- .../__tests__/ReactComponent-test.js | 12 +- .../__tests__/ReactComponentLifeCycle-test.js | 16 +- .../__tests__/ReactCompositeComponent-test.js | 40 +-- .../__tests__/ReactEmptyComponent-test.js | 48 ++-- .../__tests__/ReactMockedComponent-test.js | 2 +- .../ReactMultiChildReconcile-test.js | 2 +- .../__tests__/ReactMultiChildText-test.js | 6 +- .../__tests__/ReactStatelessComponent-test.js | 24 +- .../reconciler/__tests__/ReactUpdates-test.js | 14 +- .../utils/__tests__/PooledClass-test.js | 2 +- .../utils/__tests__/Transaction-test.js | 2 +- .../utils/__tests__/accumulateInto-test.js | 2 +- .../__tests__/traverseAllChildren-test.js | 50 ++-- src/test/MetaMatchers.js | 41 ++-- src/test/__tests__/MetaMatchers-test.js | 2 +- src/test/__tests__/ReactTestUtils-test.js | 10 +- 57 files changed, 675 insertions(+), 640 deletions(-) diff --git a/package.json b/package.json index 1b20001d2e6ff..7df476db63ee2 100644 --- a/package.json +++ b/package.json @@ -99,6 +99,7 @@ "/src", "node_modules/fbjs" ], + "testRunner": "node_modules/jest-cli/src/testRunners/jasmine/jasmine2.js", "unmockedModulePathPatterns": [ "" ] diff --git a/scripts/jest/jest.d.ts b/scripts/jest/jest.d.ts index 31fcc07dfcff9..c3e69596f8043 100644 --- a/scripts/jest/jest.d.ts +++ b/scripts/jest/jest.d.ts @@ -17,6 +17,7 @@ declare function xit(name: string, fn: any): void; interface Expect { not: Expect toThrow(message?: string): void + toThrowError(message?: string): void toBe(value: any): void toEqual(value: any): void toBeFalsy(): void diff --git a/scripts/jest/test-framework-setup.js b/scripts/jest/test-framework-setup.js index 107f6a8d43ac2..141b0fa8366f8 100644 --- a/scripts/jest/test-framework-setup.js +++ b/scripts/jest/test-framework-setup.js @@ -2,34 +2,49 @@ var env = jasmine.getEnv(); +var callCount = 0; var oldError = console.error; var newError = function() { + callCount++; oldError.apply(this, arguments); - var spec = env.currentSpec; - if (spec) { - var expectationResult = new jasmine.ExpectationResult({ - passed: false, - message: - 'Expected test not to warn. If the warning is expected, mock it ' + - 'out using spyOn(console, \'error\'); and test that the warning ' + - 'occurs.', - }); - spec.addMatcherResult(expectationResult); - } }; -console.error = newError; -// Make sure console.error is set back at the end of each test, or else the -// above logic won't work -afterEach(function() { - // TODO: Catch test cases that call spyOn() but don't inspect the mock - // properly. +console.error = newError; - if (console.error !== newError && !console.error.isSpy) { - var expectationResult = new jasmine.ExpectationResult({ - passed: false, - message: 'Test did not tear down console.error mock properly.', - }); - env.currentSpec.addMatcherResult(expectationResult); - } +env.beforeEach(() => { + callCount = 0; + jasmine.addMatchers({ + toBeReset() { + return { + compare(actual) { + // TODO: Catch test cases that call spyOn() but don't inspect the mock + // properly. + if (actual !== newError && !jasmine.isSpy(actual)) { + return { + pass: false, + message: 'Test did not tear down console.error mock properly.', + }; + } + return {pass: true}; + }, + }; + }, + toNotHaveBeenCalled() { + return { + compare(actual) { + return { + pass: callCount === 0, + message: + 'Expected test not to warn. If the warning is expected, mock ' + + 'it out using spyOn(console, \'error\'); and test that the ' + + 'warning occurs.', + }; + }, + }; + }, + }); +}); +env.afterEach(() => { + expect(console.error).toBeReset(); + expect(console.error).toNotHaveBeenCalled(); }); diff --git a/src/addons/__tests__/ReactFragment-test.js b/src/addons/__tests__/ReactFragment-test.js index 4a1b9775d62a6..2ca0302c22332 100644 --- a/src/addons/__tests__/ReactFragment-test.js +++ b/src/addons/__tests__/ReactFragment-test.js @@ -31,7 +31,7 @@ describe('ReactFragment', function() { }; var element =
{[children]}
; var container = document.createElement('div'); - expect(() => ReactDOM.render(element, container)).toThrow( + expect(() => ReactDOM.render(element, container)).toThrowError( 'Objects are not valid as a React child (found: object with keys ' + '{x, y, z}). If you meant to render a collection of children, use an ' + 'array instead or wrap the object using createFragment(object) from ' + @@ -51,7 +51,7 @@ describe('ReactFragment', function() { } } var container = document.createElement('div'); - expect(() => ReactDOM.render(, container)).toThrow( + expect(() => ReactDOM.render(, container)).toThrowError( 'Objects are not valid as a React child (found: object with keys ' + '{a, b, c}). If you meant to render a collection of children, use an ' + 'array instead or wrap the object using createFragment(object) from ' + @@ -62,7 +62,7 @@ describe('ReactFragment', function() { it('should throw if a plain object looks like an old element', function() { var oldEl = {_isReactElement: true, type: 'span', props: {}}; var container = document.createElement('div'); - expect(() => ReactDOM.render(
{oldEl}
, container)).toThrow( + expect(() => ReactDOM.render(
{oldEl}
, container)).toThrowError( 'Objects are not valid as a React child (found: object with keys ' + '{_isReactElement, type, props}). It looks like you\'re using an ' + 'element created by a different version of React. Make sure to use ' + @@ -75,8 +75,8 @@ describe('ReactFragment', function() { ReactFragment.create({1: , 2: }); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'Child objects should have non-numeric keys so ordering is preserved.' ); }); @@ -84,8 +84,8 @@ describe('ReactFragment', function() { it('should warn if passing null to createFragment', function() { spyOn(console, 'error'); ReactFragment.create(null); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'React.addons.createFragment only accepts a single object.' ); }); @@ -93,8 +93,8 @@ describe('ReactFragment', function() { it('should warn if passing an array to createFragment', function() { spyOn(console, 'error'); ReactFragment.create([]); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'React.addons.createFragment only accepts a single object.' ); }); @@ -102,8 +102,8 @@ describe('ReactFragment', function() { it('should warn if passing a ReactElement to createFragment', function() { spyOn(console, 'error'); ReactFragment.create(
); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'React.addons.createFragment does not accept a ReactElement without a ' + 'wrapper object.' ); diff --git a/src/addons/__tests__/renderSubtreeIntoContainer-test.js b/src/addons/__tests__/renderSubtreeIntoContainer-test.js index de67b7ee47947..7898af3d7fba8 100644 --- a/src/addons/__tests__/renderSubtreeIntoContainer-test.js +++ b/src/addons/__tests__/renderSubtreeIntoContainer-test.js @@ -88,7 +88,7 @@ describe('renderSubtreeIntoContainer', function() { componentDidMount: function() { expect(function() { renderSubtreeIntoContainer(, , portal); - }).toThrow('parentComponentmust be a valid React Component'); + }).toThrowError('parentComponentmust be a valid React Component'); }, }); }); diff --git a/src/addons/__tests__/update-test.js b/src/addons/__tests__/update-test.js index 05a6578ee8976..e2682a70c1527 100644 --- a/src/addons/__tests__/update-test.js +++ b/src/addons/__tests__/update-test.js @@ -25,13 +25,13 @@ describe('update', function() { expect(obj).toEqual([1]); }); it('only pushes an array', function() { - expect(update.bind(null, [], {$push: 7})).toThrow( + expect(update.bind(null, [], {$push: 7})).toThrowError( 'update(): expected spec of $push to be an array; got 7. Did you ' + 'forget to wrap your parameter in an array?' ); }); it('only pushes unto an array', function() { - expect(update.bind(null, 1, {$push: 7})).toThrow( + expect(update.bind(null, 1, {$push: 7})).toThrowError( 'update(): expected target of $push to be an array; got 1.' ); }); @@ -47,13 +47,13 @@ describe('update', function() { expect(obj).toEqual([1]); }); it('only unshifts an array', function() { - expect(update.bind(null, [], {$unshift: 7})).toThrow( + expect(update.bind(null, [], {$unshift: 7})).toThrowError( 'update(): expected spec of $unshift to be an array; got 7. Did you ' + 'forget to wrap your parameter in an array?' ); }); it('only unshifts unto an array', function() { - expect(update.bind(null, 1, {$unshift: 7})).toThrow( + expect(update.bind(null, 1, {$unshift: 7})).toThrowError( 'update(): expected target of $unshift to be an array; got 1.' ); }); @@ -69,17 +69,17 @@ describe('update', function() { expect(obj).toEqual([1, 4, 3]); }); it('only splices an array of arrays', function() { - expect(update.bind(null, [], {$splice: 1})).toThrow( + expect(update.bind(null, [], {$splice: 1})).toThrowError( 'update(): expected spec of $splice to be an array of arrays; got 1. ' + 'Did you forget to wrap your parameters in an array?' ); - expect(update.bind(null, [], {$splice: [1]})).toThrow( + expect(update.bind(null, [], {$splice: [1]})).toThrowError( 'update(): expected spec of $splice to be an array of arrays; got 1. ' + 'Did you forget to wrap your parameters in an array?' ); }); it('only splices unto an array', function() { - expect(update.bind(null, 1, {$splice: 7})).toThrow( + expect(update.bind(null, 1, {$splice: 7})).toThrowError( 'Expected $splice target to be an array; got 1' ); }); @@ -95,12 +95,12 @@ describe('update', function() { expect(obj).toEqual({a: 'b'}); }); it('only merges with an object', function() { - expect(update.bind(null, {}, {$merge: 7})).toThrow( + expect(update.bind(null, {}, {$merge: 7})).toThrowError( 'update(): $merge expects a spec of type \'object\'; got 7' ); }); it('only merges with an object', function() { - expect(update.bind(null, 7, {$merge: {a: 'b'}})).toThrow( + expect(update.bind(null, 7, {$merge: {a: 'b'}})).toThrowError( 'update(): $merge expects a target of type \'object\'; got 7' ); }); @@ -130,7 +130,7 @@ describe('update', function() { expect(obj).toEqual({v: 2}); }); it('only applies a function', function() { - expect(update.bind(null, 2, {$apply: 123})).toThrow( + expect(update.bind(null, 2, {$apply: 123})).toThrowError( 'update(): expected spec of $apply to be a function; got 123.' ); }); @@ -170,7 +170,7 @@ describe('update', function() { }); it('should require a command', function() { - expect(update.bind(null, {a: 'b'}, {a: 'c'})).toThrow( + expect(update.bind(null, {a: 'b'}, {a: 'c'})).toThrowError( 'update(): You provided a key path to update() that did not contain ' + 'one of $push, $unshift, $splice, $set, $merge, $apply. Did you ' + 'forget to include {$set: ...}?' diff --git a/src/addons/transitions/__tests__/ReactCSSTransitionGroup-test.js b/src/addons/transitions/__tests__/ReactCSSTransitionGroup-test.js index 0bf8c6bb2ff79..5d24d9b05dc59 100644 --- a/src/addons/transitions/__tests__/ReactCSSTransitionGroup-test.js +++ b/src/addons/transitions/__tests__/ReactCSSTransitionGroup-test.js @@ -45,7 +45,7 @@ describe('ReactCSSTransitionGroup', function() { ); // Warning about the missing transitionLeaveTimeout prop - expect(console.error.argsForCall.length).toBe(1); + expect(console.error.calls.count()).toBe(1); }); it('should not warn if timeouts is zero', function() { @@ -61,7 +61,7 @@ describe('ReactCSSTransitionGroup', function() { container ); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('should clean-up silently after the timeout elapses', function() { @@ -103,7 +103,7 @@ describe('ReactCSSTransitionGroup', function() { } // No warnings - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); // The leaving child has been removed expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1); diff --git a/src/isomorphic/children/__tests__/ReactChildren-test.js b/src/isomorphic/children/__tests__/ReactChildren-test.js index e638c68c1022e..76db6cf31ee94 100644 --- a/src/isomorphic/children/__tests__/ReactChildren-test.js +++ b/src/isomorphic/children/__tests__/ReactChildren-test.js @@ -23,7 +23,7 @@ describe('ReactChildren', function() { }); it('should support identity for simple', function() { - var callback = jasmine.createSpy().andCallFake(function(kid, index) { + var callback = jasmine.createSpy().and.callFake(function(kid, index) { return kid; }); @@ -35,14 +35,14 @@ describe('ReactChildren', function() { var instance =
{simpleKid}
; ReactChildren.forEach(instance.props.children, callback); expect(callback).toHaveBeenCalledWith(simpleKid, 0); - callback.reset(); + callback.calls.reset(); var mappedChildren = ReactChildren.map(instance.props.children, callback); expect(callback).toHaveBeenCalledWith(simpleKid, 0); expect(mappedChildren[0]).toEqual(); }); it('should treat single arrayless child as being in array', function() { - var callback = jasmine.createSpy().andCallFake(function(kid, index) { + var callback = jasmine.createSpy().and.callFake(function(kid, index) { return kid; }); @@ -50,14 +50,14 @@ describe('ReactChildren', function() { var instance =
{simpleKid}
; ReactChildren.forEach(instance.props.children, callback); expect(callback).toHaveBeenCalledWith(simpleKid, 0); - callback.reset(); + callback.calls.reset(); var mappedChildren = ReactChildren.map(instance.props.children, callback); expect(callback).toHaveBeenCalledWith(simpleKid, 0); expect(mappedChildren[0]).toEqual(); }); it('should treat single child in array as expected', function() { - var callback = jasmine.createSpy().andCallFake(function(kid, index) { + var callback = jasmine.createSpy().and.callFake(function(kid, index) { return kid; }); @@ -65,7 +65,7 @@ describe('ReactChildren', function() { var instance =
{[simpleKid]}
; ReactChildren.forEach(instance.props.children, callback); expect(callback).toHaveBeenCalledWith(simpleKid, 0); - callback.reset(); + callback.calls.reset(); var mappedChildren = ReactChildren.map(instance.props.children, callback); expect(callback).toHaveBeenCalledWith(simpleKid, 0); expect(mappedChildren[0]).toEqual(); @@ -124,7 +124,7 @@ describe('ReactChildren', function() { , // Map from null to something.
, ]; - var callback = jasmine.createSpy().andCallFake(function(kid, index) { + var callback = jasmine.createSpy().and.callFake(function(kid, index) { return mapped[index]; }); @@ -144,11 +144,11 @@ describe('ReactChildren', function() { expect(callback).toHaveBeenCalledWith(two, 2); expect(callback).toHaveBeenCalledWith(three, 3); expect(callback).toHaveBeenCalledWith(four, 4); - callback.reset(); + callback.calls.reset(); var mappedChildren = ReactChildren.map(instance.props.children, callback); - expect(callback.calls.length).toBe(5); + expect(callback.calls.count()).toBe(5); expect(ReactChildren.count(mappedChildren)).toBe(4); // Keys default to indices. expect([ @@ -190,7 +190,7 @@ describe('ReactChildren', function() { var fourMapped =
; var fiveMapped =
; - var callback = jasmine.createSpy().andCallFake(function(kid, index) { + var callback = jasmine.createSpy().and.callFake(function(kid, index) { return index === 0 ? zeroMapped : index === 1 ? twoMapped : index === 2 ? fourMapped : fiveMapped; @@ -216,15 +216,15 @@ describe('ReactChildren', function() { ]); ReactChildren.forEach(instance.props.children, callback); - expect(callback.calls.length).toBe(4); + expect(callback.calls.count()).toBe(4); expect(callback).toHaveBeenCalledWith(frag[0], 0); expect(callback).toHaveBeenCalledWith(frag[1], 1); expect(callback).toHaveBeenCalledWith(frag[2], 2); expect(callback).toHaveBeenCalledWith(frag[3], 3); - callback.reset(); + callback.calls.reset(); var mappedChildren = ReactChildren.map(instance.props.children, callback); - expect(callback.calls.length).toBe(4); + expect(callback.calls.count()).toBe(4); expect(callback).toHaveBeenCalledWith(frag[0], 0); expect(callback).toHaveBeenCalledWith(frag[1], 1); expect(callback).toHaveBeenCalledWith(frag[2], 2); diff --git a/src/isomorphic/classic/__tests__/ReactContextValidator-test.js b/src/isomorphic/classic/__tests__/ReactContextValidator-test.js index 972093d8f54ad..37e77d7de8f11 100644 --- a/src/isomorphic/classic/__tests__/ReactContextValidator-test.js +++ b/src/isomorphic/classic/__tests__/ReactContextValidator-test.js @@ -149,8 +149,8 @@ describe('ReactContextValidator', function() { ReactTestUtils.renderIntoDocument(); - expect(console.error.argsForCall.length).toBe(1); - expect(normalizeCodeLocInfo(console.error.argsForCall[0][0])).toBe( + expect(console.error.calls.count()).toBe(1); + expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe( 'Warning: Failed context type: ' + 'Required context `foo` was not specified in `Component`.\n' + ' in Component (at **)' @@ -177,7 +177,7 @@ describe('ReactContextValidator', function() { ); // Previous call should not error - expect(console.error.argsForCall.length).toBe(1); + expect(console.error.calls.count()).toBe(1); var ComponentInFooNumberContext = React.createClass({ childContextTypes: { @@ -197,8 +197,8 @@ describe('ReactContextValidator', function() { ReactTestUtils.renderIntoDocument(); - expect(console.error.argsForCall.length).toBe(2); - expect(normalizeCodeLocInfo(console.error.argsForCall[1][0])).toBe( + expect(console.error.calls.count()).toBe(2); + expect(normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])).toBe( 'Warning: Failed context type: ' + 'Invalid context `foo` of type `number` supplied ' + 'to `Component`, expected `string`.\n' + @@ -226,8 +226,8 @@ describe('ReactContextValidator', function() { }); ReactTestUtils.renderIntoDocument(); - expect(console.error.argsForCall.length).toBe(1); - expect(normalizeCodeLocInfo(console.error.argsForCall[0][0])).toBe( + expect(console.error.calls.count()).toBe(1); + expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe( 'Warning: Failed childContext type: ' + 'Required child context `foo` was not specified in `Component`.\n' + ' in Component (at **)' @@ -235,8 +235,8 @@ describe('ReactContextValidator', function() { ReactTestUtils.renderIntoDocument(); - expect(console.error.argsForCall.length).toBe(2); - expect(normalizeCodeLocInfo(console.error.argsForCall[1][0])).toBe( + expect(console.error.calls.count()).toBe(2); + expect(normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])).toBe( 'Warning: Failed childContext type: ' + 'Invalid child context `foo` of type `number` ' + 'supplied to `Component`, expected `string`.\n' + @@ -252,7 +252,7 @@ describe('ReactContextValidator', function() { ); // Previous calls should not log errors - expect(console.error.argsForCall.length).toBe(2); + expect(console.error.calls.count()).toBe(2); }); }); diff --git a/src/isomorphic/classic/class/__tests__/ReactBind-test.js b/src/isomorphic/classic/class/__tests__/ReactBind-test.js index bbf9d0c7da41c..5d1f4eda94a6b 100644 --- a/src/isomorphic/classic/class/__tests__/ReactBind-test.js +++ b/src/isomorphic/classic/class/__tests__/ReactBind-test.js @@ -132,8 +132,8 @@ describe('autobinding', function() { ReactTestUtils.renderIntoDocument(); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See TestBindComponent' @@ -160,7 +160,7 @@ describe('autobinding', function() { ReactTestUtils.renderIntoDocument(); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); }); diff --git a/src/isomorphic/classic/class/__tests__/ReactBindOptout-test.js b/src/isomorphic/classic/class/__tests__/ReactBindOptout-test.js index 54d3c11f5c970..39ef8f9770540 100644 --- a/src/isomorphic/classic/class/__tests__/ReactBindOptout-test.js +++ b/src/isomorphic/classic/class/__tests__/ReactBindOptout-test.js @@ -203,7 +203,7 @@ describe('autobind optout', function() { ReactTestUtils.renderIntoDocument(); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('does not warn if you pass an manually bound method to setState', function() { @@ -227,7 +227,7 @@ describe('autobind optout', function() { ReactTestUtils.renderIntoDocument(); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); }); diff --git a/src/isomorphic/classic/class/__tests__/ReactClass-test.js b/src/isomorphic/classic/class/__tests__/ReactClass-test.js index 9a5587f7b7dd0..9a4dc33a3caaa 100644 --- a/src/isomorphic/classic/class/__tests__/ReactClass-test.js +++ b/src/isomorphic/classic/class/__tests__/ReactClass-test.js @@ -26,7 +26,7 @@ describe('ReactClass-spec', function() { it('should throw when `render` is not specified', function() { expect(function() { React.createClass({}); - }).toThrow( + }).toThrowError( 'createClass(...): Class specification must implement a `render` method.' ); }); @@ -123,8 +123,8 @@ describe('ReactClass-spec', function() { return
; }, }); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: A component has a method called componentShouldUpdate(). Did you ' + 'mean shouldComponentUpdate()? The name is phrased as a question ' + 'because the function is expected to return a value.' @@ -139,8 +139,8 @@ describe('ReactClass-spec', function() { return
; }, }); - expect(console.error.argsForCall.length).toBe(2); - expect(console.error.argsForCall[1][0]).toBe( + expect(console.error.calls.count()).toBe(2); + expect(console.error.calls.argsFor(1)[0]).toBe( 'Warning: NamedComponent has a method called componentShouldUpdate(). Did you ' + 'mean shouldComponentUpdate()? The name is phrased as a question ' + 'because the function is expected to return a value.' @@ -157,8 +157,8 @@ describe('ReactClass-spec', function() { return
; }, }); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: A component has a method called componentWillRecieveProps(). Did you ' + 'mean componentWillReceiveProps()?' ); @@ -179,7 +179,7 @@ describe('ReactClass-spec', function() { return ; }, }); - }).toThrow( + }).toThrowError( 'ReactClass: You are attempting to define a reserved property, ' + '`getDefaultProps`, that shouldn\'t be on the "statics" key. Define ' + 'it as an instance property instead; it will still be accessible on ' + @@ -206,20 +206,20 @@ describe('ReactClass-spec', function() { return
; }, }); - expect(console.error.argsForCall.length).toBe(4); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(4); + expect(console.error.calls.argsFor(0)[0]).toBe( 'createClass(...): `mixins` is now a static property and should ' + 'be defined inside "statics".' ); - expect(console.error.argsForCall[1][0]).toBe( + expect(console.error.calls.argsFor(1)[0]).toBe( 'createClass(...): `propTypes` is now a static property and should ' + 'be defined inside "statics".' ); - expect(console.error.argsForCall[2][0]).toBe( + expect(console.error.calls.argsFor(2)[0]).toBe( 'createClass(...): `contextTypes` is now a static property and ' + 'should be defined inside "statics".' ); - expect(console.error.argsForCall[3][0]).toBe( + expect(console.error.calls.argsFor(3)[0]).toBe( 'createClass(...): `childContextTypes` is now a static property and ' + 'should be defined inside "statics".' ); @@ -314,7 +314,7 @@ describe('ReactClass-spec', function() { var instance = ; expect(function() { instance = ReactTestUtils.renderIntoDocument(instance); - }).toThrow( + }).toThrowError( 'Component.getInitialState(): must return an object or null' ); }); @@ -343,8 +343,8 @@ describe('ReactClass-spec', function() { }); expect(() => Component()).toThrow(); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: Something is calling a React component directly. Use a ' + 'factory or JSX instead. See: https://fb.me/react-legacyfactory' ); diff --git a/src/isomorphic/classic/class/__tests__/ReactClassMixin-test.js b/src/isomorphic/classic/class/__tests__/ReactClassMixin-test.js index f32af1e0460a2..20a140236ddcb 100644 --- a/src/isomorphic/classic/class/__tests__/ReactClassMixin-test.js +++ b/src/isomorphic/classic/class/__tests__/ReactClassMixin-test.js @@ -155,12 +155,12 @@ describe('ReactClass-mixin', function() { it('should override mixin prop types with class prop types', function() { // Sanity check... - expect(componentPropValidator).toNotBe(mixinPropValidator); + expect(componentPropValidator).not.toBe(mixinPropValidator); // Actually check... expect(TestComponentWithPropTypes.propTypes) .toBeDefined(); expect(TestComponentWithPropTypes.propTypes.value) - .toNotBe(mixinPropValidator); + .not.toBe(mixinPropValidator); expect(TestComponentWithPropTypes.propTypes.value) .toBe(componentPropValidator); }); @@ -205,7 +205,7 @@ describe('ReactClass-mixin', function() { var instance = ; expect(function() { instance = ReactTestUtils.renderIntoDocument(instance); - }).toThrow( + }).toThrowError( 'mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the ' + 'same key: `x`. This conflict may be due to a mixin; in particular, ' + 'this may be caused by two getInitialState() or getDefaultProps() ' + @@ -276,7 +276,7 @@ describe('ReactClass-mixin', function() { return ; }, }); - }).toThrow( + }).toThrowError( 'ReactClass: You are attempting to define `abc` on your component more ' + 'than once. This conflict may be due to a mixin.' ); @@ -304,7 +304,7 @@ describe('ReactClass-mixin', function() { return ; }, }); - }).toThrow( + }).toThrowError( 'ReactClass: You are attempting to define `abc` on your component ' + 'more than once. This conflict may be due to a mixin.' ); @@ -319,7 +319,7 @@ describe('ReactClass-mixin', function() { return ; }, }); - }).toThrow( + }).toThrowError( 'ReactClass: You\'re attempting to use a component as a mixin. ' + 'Instead, just use a regular object.' ); @@ -340,7 +340,7 @@ describe('ReactClass-mixin', function() { return ; }, }); - }).toThrow( + }).toThrowError( 'ReactClass: You\'re attempting to use a component class or function ' + 'as a mixin. Instead, just use a regular object.' ); diff --git a/src/isomorphic/classic/element/__tests__/ReactElement-test.js b/src/isomorphic/classic/element/__tests__/ReactElement-test.js index 011dbf9aa8b68..4732d567d8e18 100644 --- a/src/isomorphic/classic/element/__tests__/ReactElement-test.js +++ b/src/isomorphic/classic/element/__tests__/ReactElement-test.js @@ -76,10 +76,10 @@ describe('ReactElement', function() { ); }, }); - expect(console.error.calls.length).toBe(0); + expect(console.error.calls.count()).toBe(0); ReactDOM.render(, container); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'Child: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + @@ -104,10 +104,10 @@ describe('ReactElement', function() { ); }, }); - expect(console.error.calls.length).toBe(0); + expect(console.error.calls.count()).toBe(0); ReactDOM.render(, container); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'Child: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + @@ -208,7 +208,7 @@ describe('ReactElement', function() { children: 'text', }, a); expect(element.props.children).toBe(a); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('does not override children if no rest args are provided', function() { @@ -217,7 +217,7 @@ describe('ReactElement', function() { children: 'text', }); expect(element.props.children).toBe('text'); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('overrides children if null is provided as an argument', function() { @@ -226,7 +226,7 @@ describe('ReactElement', function() { children: 'text', }, null); expect(element.props.children).toBe(null); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('overrides children if undefined is provided as an argument', function() { @@ -248,7 +248,7 @@ describe('ReactElement', function() { var c = 3; var element = React.createFactory(ComponentClass)(null, a, b, c); expect(element.props.children).toEqual([1, 2, 3]); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); // NOTE: We're explicitly not using JSX here. This is intended to test @@ -272,7 +272,7 @@ describe('ReactElement', function() { var element = React.createElement(StaticMethodComponentClass); expect(element.type.someStaticMethod()).toBe('someReturnValue'); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); // NOTE: We're explicitly not using JSX here. This is intended to test @@ -440,7 +440,7 @@ describe('ReactElement', function() { }); var test = ReactTestUtils.renderIntoDocument(); expect(test.props.value).toBeNaN(); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); // NOTE: We're explicitly not using JSX here. This is intended to test diff --git a/src/isomorphic/classic/element/__tests__/ReactElementClone-test.js b/src/isomorphic/classic/element/__tests__/ReactElementClone-test.js index 322bcfb174e9f..ab57c8cae2fe4 100644 --- a/src/isomorphic/classic/element/__tests__/ReactElementClone-test.js +++ b/src/isomorphic/classic/element/__tests__/ReactElementClone-test.js @@ -71,8 +71,8 @@ describe('ReactElementClone', function() { React.cloneElement('div', {foo: 1}); expect(console.error).not.toHaveBeenCalled(); React.cloneElement('div', Object.create({foo: 1})); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'React.cloneElement(...): Expected props argument to be a plain object. ' + 'Properties defined in its prototype chain will be ignored.' ); @@ -213,8 +213,8 @@ describe('ReactElementClone', function() { React.cloneElement(
, null, [
,
]); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'Each child in an array or iterator should have a unique "key" prop.' ); }); @@ -224,7 +224,7 @@ describe('ReactElementClone', function() { React.cloneElement(
, null, [
,
]); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('does not warn when the element is directly in rest args', function() { @@ -232,7 +232,7 @@ describe('ReactElementClone', function() { React.cloneElement(
, null,
,
); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('does not warn when the array contains a non-element', function() { @@ -240,7 +240,7 @@ describe('ReactElementClone', function() { React.cloneElement(
, null, [{}, {}]); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('should check declared prop types after clone', function() { @@ -267,8 +267,8 @@ describe('ReactElementClone', function() { }, }); ReactTestUtils.renderIntoDocument(React.createElement(GrandParent)); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: Failed prop type: ' + 'Invalid prop `color` of type `number` supplied to `Component`, ' + 'expected `string`.\n' + diff --git a/src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js b/src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js index 69872e3dd30d2..fe7acf3e60930 100644 --- a/src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js +++ b/src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js @@ -44,8 +44,8 @@ describe('ReactElementValidator', function() { Component(null, [Component(), Component()]); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'Each child in an array or iterator should have a unique "key" prop.' ); }); @@ -74,8 +74,8 @@ describe('ReactElementValidator', function() { React.createElement(ComponentWrapper) ); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'Each child in an array or iterator should have a unique "key" prop. ' + 'Check the render method of `InnerClass`. ' + 'It was passed a child from ComponentWrapper. ' @@ -98,8 +98,8 @@ describe('ReactElementValidator', function() { ]; ReactTestUtils.renderIntoDocument({divs}); - expect(console.error.argsForCall.length).toBe(1); - expect(normalizeCodeLocInfo(console.error.argsForCall[0][0])).toBe( + expect(console.error.calls.count()).toBe(1); + expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe( 'Warning: Each child in an array or iterator should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for more information.\n' + ' in div (at **)' @@ -115,8 +115,8 @@ describe('ReactElementValidator', function() { ]; ReactTestUtils.renderIntoDocument(
{divs}
); - expect(console.error.argsForCall.length).toBe(1); - expect(normalizeCodeLocInfo(console.error.argsForCall[0][0])).toBe( + expect(console.error.calls.count()).toBe(1); + expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe( 'Warning: Each child in an array or iterator should have a unique ' + '"key" prop. Check the top-level render call using
. See ' + 'https://fb.me/react-warning-keys for more information.\n' + @@ -147,8 +147,8 @@ describe('ReactElementValidator', function() { ReactTestUtils.renderIntoDocument(); - expect(console.error.argsForCall.length).toBe(1); - expect(normalizeCodeLocInfo(console.error.argsForCall[0][0])).toBe( + expect(console.error.calls.count()).toBe(1); + expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe( 'Warning: Each child in an array or iterator should have a unique ' + '"key" prop. Check the render method of `Component`. See ' + 'https://fb.me/react-warning-keys for more information.\n' + @@ -180,7 +180,7 @@ describe('ReactElementValidator', function() { ); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('warns for keys for iterables of elements in rest args', function() { @@ -201,8 +201,8 @@ describe('ReactElementValidator', function() { Component(null, iterable); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'Each child in an array or iterator should have a unique "key" prop.' ); }); @@ -213,7 +213,7 @@ describe('ReactElementValidator', function() { Component(null, [Component({key: '#1'}), Component({key: '#2'})]); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('does not warns for iterable elements with keys', function() { @@ -237,7 +237,7 @@ describe('ReactElementValidator', function() { Component(null, iterable); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('does not warn when the element is directly in rest args', function() { @@ -246,7 +246,7 @@ describe('ReactElementValidator', function() { Component(null, Component(), Component()); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('does not warn when the array contains a non-element', function() { @@ -255,7 +255,7 @@ describe('ReactElementValidator', function() { Component(null, [{}, {}]); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); // TODO: These warnings currently come from the composite component, but @@ -280,7 +280,7 @@ describe('ReactElementValidator', function() { }, }); ReactTestUtils.renderIntoDocument(React.createElement(ParentComp)); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: Failed prop type: ' + 'Invalid prop `color` of type `number` supplied to `MyComp`, ' + 'expected `string`.\n' + @@ -295,29 +295,29 @@ describe('ReactElementValidator', function() { React.createElement(null); React.createElement(true); React.createElement(123); - expect(console.error.calls.length).toBe(4); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(4); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: React.createElement: type should not be null, undefined, ' + 'boolean, or number. It should be a string (for DOM elements) or a ' + 'ReactClass (for composite components).' ); - expect(console.error.argsForCall[1][0]).toBe( + expect(console.error.calls.argsFor(1)[0]).toBe( 'Warning: React.createElement: type should not be null, undefined, ' + 'boolean, or number. It should be a string (for DOM elements) or a ' + 'ReactClass (for composite components).' ); - expect(console.error.argsForCall[2][0]).toBe( + expect(console.error.calls.argsFor(2)[0]).toBe( 'Warning: React.createElement: type should not be null, undefined, ' + 'boolean, or number. It should be a string (for DOM elements) or a ' + 'ReactClass (for composite components).' ); - expect(console.error.argsForCall[3][0]).toBe( + expect(console.error.calls.argsFor(3)[0]).toBe( 'Warning: React.createElement: type should not be null, undefined, ' + 'boolean, or number. It should be a string (for DOM elements) or a ' + 'ReactClass (for composite components).' ); React.createElement('div'); - expect(console.error.calls.length).toBe(4); + expect(console.error.calls.count()).toBe(4); }); it('includes the owner name when passing null, undefined, boolean, or number', function() { @@ -329,13 +329,13 @@ describe('ReactElementValidator', function() { }); expect(function() { ReactTestUtils.renderIntoDocument(React.createElement(ParentComp)); - }).toThrow( + }).toThrowError( 'Element type is invalid: expected a string (for built-in components) ' + 'or a class/function (for composite components) but got: null. Check ' + 'the render method of `ParentComp`.' ); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: React.createElement: type should not be null, undefined, ' + 'boolean, or number. It should be a string (for DOM elements) or a ' + 'ReactClass (for composite components). Check the render method of ' + @@ -358,8 +358,8 @@ describe('ReactElementValidator', function() { ReactTestUtils.renderIntoDocument(React.createElement(Component)); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: Failed prop type: ' + 'Required prop `prop` was not specified in `Component`.\n' + ' in Component' @@ -383,8 +383,8 @@ describe('ReactElementValidator', function() { React.createElement(Component, {prop:null}) ); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: Failed prop type: ' + 'Required prop `prop` was not specified in `Component`.\n' + ' in Component' @@ -410,14 +410,14 @@ describe('ReactElementValidator', function() { React.createElement(Component, {prop: 42}) ); - expect(console.error.calls.length).toBe(2); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(2); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: Failed prop type: ' + 'Required prop `prop` was not specified in `Component`.\n' + ' in Component' ); - expect(console.error.argsForCall[1][0]).toBe( + expect(console.error.calls.argsFor(1)[0]).toBe( 'Warning: Failed prop type: ' + 'Invalid prop `prop` of type `number` supplied to ' + '`Component`, expected `string`.\n' + @@ -429,7 +429,7 @@ describe('ReactElementValidator', function() { ); // Should not error for strings - expect(console.error.calls.length).toBe(2); + expect(console.error.calls.count()).toBe(2); }); it('should warn if a PropType creator is used as a PropType', function() { @@ -448,8 +448,8 @@ describe('ReactElementValidator', function() { React.createElement(Component, {myProp: {value: 'hi'}}) ); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: Component: type specification of prop `myProp` is invalid; ' + 'the type checker function must return `null` or an `Error` but ' + 'returned a function. You may have forgotten to pass an argument to ' + @@ -467,14 +467,14 @@ describe('ReactElementValidator', function() { }); var TestFactory = React.createFactory(TestComponent); expect(TestFactory.type).toBe(TestComponent); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: Factory.type is deprecated. Access the class directly before ' + 'passing it to createFactory.' ); // Warn once, not again expect(TestFactory.type).toBe(TestComponent); - expect(console.error.argsForCall.length).toBe(1); + expect(console.error.calls.count()).toBe(1); }); it('does not warn when using DOM node as children', function() { @@ -491,7 +491,7 @@ describe('ReactElementValidator', function() { var node = document.createElement('div'); // This shouldn't cause a stack overflow or any other problems (#3883) ReactTestUtils.renderIntoDocument({node}); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('should not enumerate enumerable numbers (#4776)', function() { @@ -534,8 +534,8 @@ describe('ReactElementValidator', function() { spyOn(console, 'error'); var Foo = undefined; void {[
]}; - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: React.createElement: type should not be null, undefined, ' + 'boolean, or number. It should be a string (for DOM elements) or a ' + 'ReactClass (for composite components).' diff --git a/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js b/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js index b217438abe5c4..14559720aeb0d 100644 --- a/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js +++ b/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js @@ -271,7 +271,7 @@ describe('ReactPropTypes', function() { var instance = } />; instance = ReactTestUtils.renderIntoDocument(instance); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('should warn when passing no label and isRequired is set', () => { @@ -280,7 +280,7 @@ describe('ReactPropTypes', function() { var instance = ; instance = ReactTestUtils.renderIntoDocument(instance); - expect(console.error.argsForCall.length).toBe(1); + expect(console.error.calls.count()).toBe(1); }); it('should be implicitly optional and not warn without values', function() { @@ -421,7 +421,7 @@ describe('ReactPropTypes', function() { k4: null, k5: undefined, })); - expect(console.error.calls).toEqual([]); + expect(console.error.calls.count()).toBe(0); }); it('should not warn for iterables', function() { @@ -849,8 +849,8 @@ describe('ReactPropTypes', function() { var instance = ; instance = ReactTestUtils.renderIntoDocument(instance); - expect(spy.argsForCall.length).toBe(1); - expect(spy.argsForCall[0][1]).toBe('num'); + expect(spy.calls.count()).toBe(1); + expect(spy.calls.argsFor(0)[1]).toBe('num'); }); it('should have been called even if the prop is not present', function() { @@ -866,14 +866,13 @@ describe('ReactPropTypes', function() { var instance = ; instance = ReactTestUtils.renderIntoDocument(instance); - expect(spy.argsForCall.length).toBe(1); - expect(spy.argsForCall[0][1]).toBe('num'); + expect(spy.calls.count()).toBe(1); + expect(spy.calls.argsFor(0)[1]).toBe('num'); }); it('should have received the validator\'s return value', function() { spyOn(console, 'error'); - - var spy = jasmine.createSpy().andCallFake( + var spy = jasmine.createSpy().and.callFake( function(props, propName, componentName) { if (props[propName] !== 5) { return new Error('num must be 5!'); @@ -890,9 +889,9 @@ describe('ReactPropTypes', function() { var instance = ; instance = ReactTestUtils.renderIntoDocument(instance); - expect(console.error.argsForCall.length).toBe(1); + expect(console.error.calls.count()).toBe(1); expect( - console.error.argsForCall[0][0].replace(/\(at .+?:\d+\)/g, '(at **)') + console.error.calls.argsFor(0)[0].replace(/\(at .+?:\d+\)/g, '(at **)') ).toBe( 'Warning: Failed prop type: num must be 5!\n' + ' in Component (at **)' @@ -902,8 +901,7 @@ describe('ReactPropTypes', function() { it('should not warn if the validator returned null', function() { spyOn(console, 'error'); - - var spy = jasmine.createSpy().andCallFake( + var spy = jasmine.createSpy().and.callFake( function(props, propName, componentName) { return null; } @@ -918,7 +916,7 @@ describe('ReactPropTypes', function() { var instance = ; instance = ReactTestUtils.renderIntoDocument(instance); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); } ); }); diff --git a/src/isomorphic/modern/class/__tests__/ReactCoffeeScriptClass-test.coffee b/src/isomorphic/modern/class/__tests__/ReactCoffeeScriptClass-test.coffee index e7b1f574c579a..88d12af471387 100644 --- a/src/isomorphic/modern/class/__tests__/ReactCoffeeScriptClass-test.coffee +++ b/src/isomorphic/modern/class/__tests__/ReactCoffeeScriptClass-test.coffee @@ -51,8 +51,8 @@ describe 'ReactCoffeeScriptClass', -> expect(-> ReactDOM.render React.createElement(Foo), container ).toThrow() - expect(console.error.calls.length).toBe(1) - expect(console.error.argsForCall[0][0]).toContain('No `render` method found on the returned component instance') + expect(console.error.calls.count()).toBe(1) + expect(console.error.calls.argsFor(0)[0]).toContain('No `render` method found on the returned component instance') it 'renders a simple stateless component with prop', -> class Foo extends React.Component @@ -153,7 +153,7 @@ describe 'ReactCoffeeScriptClass', -> expect(-> test React.createElement(Foo), 'span', '' - ).toThrow( + ).toThrowError( 'Foo.state: must be set to an object or null' ) @@ -292,17 +292,17 @@ describe 'ReactCoffeeScriptClass', -> test React.createElement(Foo), 'SPAN', 'foo' expect(getInitialStateWasCalled).toBe false expect(getDefaultPropsWasCalled).toBe false - expect(console.error.calls.length).toBe 4 - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe 4 + expect(console.error.calls.argsFor(0)[0]).toContain( 'getInitialState was defined on Foo, a plain JavaScript class.' ) - expect(console.error.argsForCall[1][0]).toContain( + expect(console.error.calls.argsFor(1)[0]).toContain( 'getDefaultProps was defined on Foo, a plain JavaScript class.' ) - expect(console.error.argsForCall[2][0]).toContain( + expect(console.error.calls.argsFor(2)[0]).toContain( 'propTypes was defined as an instance property on Foo.' ) - expect(console.error.argsForCall[3][0]).toContain( + expect(console.error.calls.argsFor(3)[0]).toContain( 'contextTypes was defined as an instance property on Foo.' ) @@ -317,8 +317,8 @@ describe 'ReactCoffeeScriptClass', -> className: 'foo' test React.createElement(NamedComponent), 'SPAN', 'foo' - expect(console.error.calls.length).toBe 1 - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe 1 + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: NamedComponent has a method called componentShouldUpdate(). Did you mean shouldComponentUpdate()? The name is phrased as a question because the function is expected to return a value.' @@ -335,8 +335,8 @@ describe 'ReactCoffeeScriptClass', -> className: 'foo' test React.createElement(NamedComponent), 'SPAN', 'foo' - expect(console.error.calls.length).toBe 1 - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe 1 + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: NamedComponent has a method called componentWillRecieveProps(). Did you mean componentWillReceiveProps()?' ) @@ -349,11 +349,11 @@ describe 'ReactCoffeeScriptClass', -> expect(-> instance.isMounted()).toThrow() expect(-> instance.setProps name: 'bar').toThrow() expect(-> instance.replaceProps name: 'bar').toThrow() - expect(console.error.calls.length).toBe 2 - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe 2 + expect(console.error.calls.argsFor(0)[0]).toContain( 'replaceState(...) is deprecated in plain JavaScript React classes' ) - expect(console.error.argsForCall[1][0]).toContain( + expect(console.error.calls.argsFor(1)[0]).toContain( 'isMounted(...) is deprecated in plain JavaScript React classes' ) diff --git a/src/isomorphic/modern/class/__tests__/ReactES6Class-test.js b/src/isomorphic/modern/class/__tests__/ReactES6Class-test.js index 17a2414c53d22..de2a5e591c6a4 100644 --- a/src/isomorphic/modern/class/__tests__/ReactES6Class-test.js +++ b/src/isomorphic/modern/class/__tests__/ReactES6Class-test.js @@ -61,8 +61,8 @@ describe('ReactES6Class', function() { class Foo extends React.Component { } expect(() => ReactDOM.render(, container)).toThrow(); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: Foo(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.' ); @@ -173,7 +173,7 @@ describe('ReactES6Class', function() { return ; } } - expect(() => test(, 'span', '')).toThrow( + expect(() => test(, 'span', '')).toThrowError( 'Foo.state: must be set to an object or null' ); }); @@ -339,17 +339,17 @@ describe('ReactES6Class', function() { test(, 'SPAN', 'foo'); expect(getInitialStateWasCalled).toBe(false); expect(getDefaultPropsWasCalled).toBe(false); - expect(console.error.calls.length).toBe(4); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(4); + expect(console.error.calls.argsFor(0)[0]).toContain( 'getInitialState was defined on Foo, a plain JavaScript class.' ); - expect(console.error.argsForCall[1][0]).toContain( + expect(console.error.calls.argsFor(1)[0]).toContain( 'getDefaultProps was defined on Foo, a plain JavaScript class.' ); - expect(console.error.argsForCall[2][0]).toContain( + expect(console.error.calls.argsFor(2)[0]).toContain( 'propTypes was defined as an instance property on Foo.' ); - expect(console.error.argsForCall[3][0]).toContain( + expect(console.error.calls.argsFor(3)[0]).toContain( 'contextTypes was defined as an instance property on Foo.' ); }); @@ -367,8 +367,8 @@ describe('ReactES6Class', function() { } test(, 'SPAN', 'foo'); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: ' + 'NamedComponent has a method called componentShouldUpdate(). Did you ' + 'mean shouldComponentUpdate()? The name is phrased as a question ' + @@ -389,8 +389,8 @@ describe('ReactES6Class', function() { } test(, 'SPAN', 'foo'); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: ' + 'NamedComponent has a method called componentWillRecieveProps(). Did ' + 'you mean componentWillReceiveProps()?' @@ -404,11 +404,11 @@ describe('ReactES6Class', function() { expect(() => instance.isMounted()).toThrow(); expect(() => instance.setProps({name: 'bar'})).toThrow(); expect(() => instance.replaceProps({name: 'bar'})).toThrow(); - expect(console.error.calls.length).toBe(2); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(2); + expect(console.error.calls.argsFor(0)[0]).toContain( 'replaceState(...) is deprecated in plain JavaScript React classes' ); - expect(console.error.argsForCall[1][0]).toContain( + expect(console.error.calls.argsFor(1)[0]).toContain( 'isMounted(...) is deprecated in plain JavaScript React classes' ); }); diff --git a/src/isomorphic/modern/class/__tests__/ReactTypeScriptClass-test.ts b/src/isomorphic/modern/class/__tests__/ReactTypeScriptClass-test.ts index 44298bda154d0..fe6d4910de290 100644 --- a/src/isomorphic/modern/class/__tests__/ReactTypeScriptClass-test.ts +++ b/src/isomorphic/modern/class/__tests__/ReactTypeScriptClass-test.ts @@ -319,8 +319,8 @@ describe('ReactTypeScriptClass', function() { expect(() => ReactDOM.render(React.createElement(Empty), container)).toThrow(); - expect((console.error).argsForCall.length).toBe(1); - expect((console.error).argsForCall[0][0]).toBe( + expect((console.error).calls.count()).toBe(1); + expect((console.error).calls.argsFor(0)[0]).toBe( 'Warning: Empty(...): No `render` method found on the returned ' + 'component instance: you may have forgotten to define `render`.' ); @@ -361,15 +361,15 @@ describe('ReactTypeScriptClass', function() { it('should throw with non-object in the initial state property', function() { expect(() => test(React.createElement(ArrayState), 'span', '')) - .toThrow( + .toThrowError( 'ArrayState.state: must be set to an object or null' ); expect(() => test(React.createElement(StringState), 'span', '')) - .toThrow( + .toThrowError( 'StringState.state: must be set to an object or null' ); expect(() => test(React.createElement(NumberState), 'span', '')) - .toThrow( + .toThrowError( 'NumberState.state: must be set to an object or null' ); }); @@ -437,19 +437,19 @@ describe('ReactTypeScriptClass', function() { test(React.createElement(ClassicProperties), 'SPAN', 'foo'); expect(getInitialStateWasCalled).toBe(false); expect(getDefaultPropsWasCalled).toBe(false); - expect((console.error).argsForCall.length).toBe(4); - expect((console.error).argsForCall[0][0]).toContain( + expect((console.error).calls.count()).toBe(4); + expect((console.error).calls.argsFor(0)[0]).toContain( 'getInitialState was defined on ClassicProperties, ' + 'a plain JavaScript class.' ); - expect((console.error).argsForCall[1][0]).toContain( + expect((console.error).calls.argsFor(1)[0]).toContain( 'getDefaultProps was defined on ClassicProperties, ' + 'a plain JavaScript class.' ); - expect((console.error).argsForCall[2][0]).toContain( + expect((console.error).calls.argsFor(2)[0]).toContain( 'propTypes was defined as an instance property on ClassicProperties.' ); - expect((console.error).argsForCall[3][0]).toContain( + expect((console.error).calls.argsFor(3)[0]).toContain( 'contextTypes was defined as an instance property on ClassicProperties.' ); }); @@ -459,8 +459,8 @@ describe('ReactTypeScriptClass', function() { test(React.createElement(MisspelledComponent1), 'SPAN', 'foo'); - expect((console.error).argsForCall.length).toBe(1); - expect((console.error).argsForCall[0][0]).toBe( + expect((console.error).calls.count()).toBe(1); + expect((console.error).calls.argsFor(0)[0]).toBe( 'Warning: ' + 'MisspelledComponent1 has a method called componentShouldUpdate(). Did ' + 'you mean shouldComponentUpdate()? The name is phrased as a question ' + @@ -473,8 +473,8 @@ describe('ReactTypeScriptClass', function() { test(React.createElement(MisspelledComponent2), 'SPAN', 'foo'); - expect((console.error).argsForCall.length).toBe(1); - expect((console.error).argsForCall[0][0]).toBe( + expect((console.error).calls.count()).toBe(1); + expect((console.error).calls.argsFor(0)[0]).toBe( 'Warning: ' + 'MisspelledComponent2 has a method called componentWillRecieveProps(). ' + 'Did you mean componentWillReceiveProps()?' @@ -491,11 +491,11 @@ describe('ReactTypeScriptClass', function() { expect(() => instance.isMounted()).toThrow(); expect(() => instance.setProps({ name: 'bar' })).toThrow(); expect(() => instance.replaceProps({ name: 'bar' })).toThrow(); - expect((console.error).argsForCall.length).toBe(2); - expect((console.error).argsForCall[0][0]).toContain( + expect((console.error).calls.count()).toBe(2); + expect((console.error).calls.argsFor(0)[0]).toContain( 'replaceState(...) is deprecated in plain JavaScript React classes' ); - expect((console.error).argsForCall[1][0]).toContain( + expect((console.error).calls.argsFor(1)[0]).toContain( 'isMounted(...) is deprecated in plain JavaScript React classes' ); }); diff --git a/src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js b/src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js index 5adf59d503d4b..2e70b0253eccc 100644 --- a/src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js +++ b/src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js @@ -100,21 +100,21 @@ describe('ReactJSXElement', function() { var a = 1; var element = {a}; expect(element.props.children).toBe(a); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('does not override children if no JSX children are provided', function() { spyOn(console, 'error'); var element = ; expect(element.props.children).toBe('text'); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('overrides children if null is provided as a JSX child', function() { spyOn(console, 'error'); var element = {null}; expect(element.props.children).toBe(null); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('overrides children if undefined is provided as an argument', function() { @@ -136,7 +136,7 @@ describe('ReactJSXElement', function() { var c = 3; var element = {a}{b}{c}; expect(element.props.children).toEqual([1, 2, 3]); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('allows static methods to be called using the type property', function() { @@ -153,7 +153,7 @@ describe('ReactJSXElement', function() { var element = ; expect(element.type.someStaticMethod()).toBe('someReturnValue'); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('identifies valid elements', function() { diff --git a/src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js b/src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js index c6429dfc24097..827ab73ee505f 100644 --- a/src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js +++ b/src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js @@ -47,8 +47,8 @@ describe('ReactJSXElementValidator', function() { void {[, ]}; - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'Each child in an array or iterator should have a unique "key" prop.' ); }); @@ -74,8 +74,8 @@ describe('ReactJSXElementValidator', function() { ReactTestUtils.renderIntoDocument(); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'Each child in an array or iterator should have a unique "key" prop. ' + 'Check the render method of `InnerComponent`. ' + 'It was passed a child from ComponentWrapper. ' @@ -99,8 +99,8 @@ describe('ReactJSXElementValidator', function() { void {iterable}; - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'Each child in an array or iterator should have a unique "key" prop.' ); }); @@ -110,7 +110,7 @@ describe('ReactJSXElementValidator', function() { void {[, ]}; - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('does not warns for iterable elements with keys', function() { @@ -133,7 +133,7 @@ describe('ReactJSXElementValidator', function() { void {iterable}; - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('does not warn for numeric keys in entry iterable as a child', function() { @@ -154,7 +154,7 @@ describe('ReactJSXElementValidator', function() { void {iterable}; - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('does not warn when the element is directly as children', function() { @@ -162,7 +162,7 @@ describe('ReactJSXElementValidator', function() { void ; - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('does not warn when the child array contains non-elements', function() { @@ -170,7 +170,7 @@ describe('ReactJSXElementValidator', function() { void {[{}, {}]}; - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); // TODO: These warnings currently come from the composite component, but @@ -196,7 +196,7 @@ describe('ReactJSXElementValidator', function() { } ReactTestUtils.renderIntoDocument(); expect( - console.error.argsForCall[0][0].replace(/\(at .+?:\d+\)/g, '(at **)') + console.error.calls.argsFor(0)[0].replace(/\(at .+?:\d+\)/g, '(at **)') ).toBe( 'Warning: Failed prop type: ' + 'Invalid prop `color` of type `number` supplied to `MyComp`, ' + @@ -217,25 +217,25 @@ describe('ReactJSXElementValidator', function() { void ; void ; void ; - expect(console.error.calls.length).toBe(4); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(4); + expect(console.error.calls.argsFor(0)[0]).toContain( 'type should not be null, undefined, boolean, or number. It should be ' + 'a string (for DOM elements) or a ReactClass (for composite components).' ); - expect(console.error.argsForCall[1][0]).toContain( + expect(console.error.calls.argsFor(1)[0]).toContain( 'type should not be null, undefined, boolean, or number. It should be ' + 'a string (for DOM elements) or a ReactClass (for composite components).' ); - expect(console.error.argsForCall[2][0]).toContain( + expect(console.error.calls.argsFor(2)[0]).toContain( 'type should not be null, undefined, boolean, or number. It should be ' + 'a string (for DOM elements) or a ReactClass (for composite components).' ); - expect(console.error.argsForCall[3][0]).toContain( + expect(console.error.calls.argsFor(3)[0]).toContain( 'type should not be null, undefined, boolean, or number. It should be ' + 'a string (for DOM elements) or a ReactClass (for composite components).' ); void
; - expect(console.error.calls.length).toBe(4); + expect(console.error.calls.count()).toBe(4); }); it('should check default prop values', function() { @@ -245,9 +245,9 @@ describe('ReactJSXElementValidator', function() { ReactTestUtils.renderIntoDocument(); - expect(console.error.calls.length).toBe(1); + expect(console.error.calls.count()).toBe(1); expect( - console.error.argsForCall[0][0].replace(/\(at .+?:\d+\)/g, '(at **)') + console.error.calls.argsFor(0)[0].replace(/\(at .+?:\d+\)/g, '(at **)') ).toBe( 'Warning: Failed prop type: ' + 'Required prop `prop` was not specified in `RequiredPropComponent`.\n' + @@ -260,9 +260,9 @@ describe('ReactJSXElementValidator', function() { ReactTestUtils.renderIntoDocument(); - expect(console.error.calls.length).toBe(1); + expect(console.error.calls.count()).toBe(1); expect( - console.error.argsForCall[0][0].replace(/\(at .+?:\d+\)/g, '(at **)') + console.error.calls.argsFor(0)[0].replace(/\(at .+?:\d+\)/g, '(at **)') ).toBe( 'Warning: Failed prop type: ' + 'Required prop `prop` was not specified in `RequiredPropComponent`.\n' + @@ -276,9 +276,9 @@ describe('ReactJSXElementValidator', function() { ReactTestUtils.renderIntoDocument(); ReactTestUtils.renderIntoDocument(); - expect(console.error.calls.length).toBe(2); + expect(console.error.calls.count()).toBe(2); expect( - console.error.argsForCall[0][0].replace(/\(at .+?:\d+\)/g, '(at **)') + console.error.calls.argsFor(0)[0].replace(/\(at .+?:\d+\)/g, '(at **)') ).toBe( 'Warning: Failed prop type: ' + 'Required prop `prop` was not specified in `RequiredPropComponent`.\n' + @@ -286,7 +286,7 @@ describe('ReactJSXElementValidator', function() { ); expect( - console.error.argsForCall[1][0].replace(/\(at .+?:\d+\)/g, '(at **)') + console.error.calls.argsFor(1)[0].replace(/\(at .+?:\d+\)/g, '(at **)') ).toBe( 'Warning: Failed prop type: ' + 'Invalid prop `prop` of type `number` supplied to ' + @@ -297,7 +297,7 @@ describe('ReactJSXElementValidator', function() { ReactTestUtils.renderIntoDocument(); // Should not error for strings - expect(console.error.calls.length).toBe(2); + expect(console.error.calls.count()).toBe(2); }); it('should warn on invalid prop types', function() { @@ -315,8 +315,8 @@ describe('ReactJSXElementValidator', function() { prop: null, }; ReactTestUtils.renderIntoDocument(); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'NullPropTypeComponent: prop type `prop` is invalid; it must be a ' + 'function, usually from React.PropTypes.' ); @@ -333,8 +333,8 @@ describe('ReactJSXElementValidator', function() { prop: null, }; ReactTestUtils.renderIntoDocument(); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'NullContextTypeComponent: context type `prop` is invalid; it must ' + 'be a function, usually from React.PropTypes.' ); @@ -351,8 +351,8 @@ describe('ReactJSXElementValidator', function() { prop: 'foo', }); ReactTestUtils.renderIntoDocument(); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'getDefaultProps is only used on classic React.createClass definitions.' + ' Use a static property named `defaultProps` instead.' ); diff --git a/src/renderers/dom/__tests__/ReactDOMProduction-test.js b/src/renderers/dom/__tests__/ReactDOMProduction-test.js index dd5a96a988596..718909ed86894 100644 --- a/src/renderers/dom/__tests__/ReactDOMProduction-test.js +++ b/src/renderers/dom/__tests__/ReactDOMProduction-test.js @@ -37,7 +37,7 @@ describe('ReactDOMProduction', function() { spyOn(console, 'error'); warning(false, 'Do cows go moo?'); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('should use prod React', function() { @@ -46,7 +46,7 @@ describe('ReactDOMProduction', function() { // no key warning void
{[]}
; - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('should handle a simple flow', function() { diff --git a/src/renderers/dom/client/__tests__/ReactBrowserEventEmitter-test.js b/src/renderers/dom/client/__tests__/ReactBrowserEventEmitter-test.js index 9de6b2e8e2862..009bc5d223608 100644 --- a/src/renderers/dom/client/__tests__/ReactBrowserEventEmitter-test.js +++ b/src/renderers/dom/client/__tests__/ReactBrowserEventEmitter-test.js @@ -271,7 +271,7 @@ describe('ReactBrowserEventEmitter', function() { expect(idCallOrder[0]).toBe(getInternal(CHILD)); expect(idCallOrder[1]).toBe(getInternal(PARENT)); expect(idCallOrder[2]).toBe(getInternal(GRANDPARENT)); - expect(console.error.calls.length).toEqual(0); + expect(console.error.calls.count()).toEqual(0); }); /** @@ -388,7 +388,7 @@ describe('ReactBrowserEventEmitter', function() { spyOn(EventListener, 'listen'); ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document); ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document); - expect(EventListener.listen.calls.length).toBe(1); + expect(EventListener.listen.calls.count()).toBe(1); }); it('should work with event plugins without dependencies', function() { @@ -396,7 +396,7 @@ describe('ReactBrowserEventEmitter', function() { ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document); - expect(EventListener.listen.argsForCall[0][1]).toBe('click'); + expect(EventListener.listen.calls.argsFor(0)[1]).toBe('click'); }); it('should work with event plugins with dependencies', function() { @@ -406,8 +406,8 @@ describe('ReactBrowserEventEmitter', function() { ReactBrowserEventEmitter.listenTo(ON_CHANGE_KEY, document); var setEventListeners = []; - var listenCalls = EventListener.listen.argsForCall; - var captureCalls = EventListener.capture.argsForCall; + var listenCalls = EventListener.listen.calls.allArgs(); + var captureCalls = EventListener.capture.calls.allArgs(); for (var i = 0; i < listenCalls.length; i++) { setEventListeners.push(listenCalls[i][1]); } diff --git a/src/renderers/dom/client/__tests__/ReactDOM-test.js b/src/renderers/dom/client/__tests__/ReactDOM-test.js index 9c3cef57f90df..eb4aa1ab90a41 100644 --- a/src/renderers/dom/client/__tests__/ReactDOM-test.js +++ b/src/renderers/dom/client/__tests__/ReactDOM-test.js @@ -115,7 +115,7 @@ describe('ReactDOM', function() { spyOn(console, 'error'); var element = React.DOM.div(); expect(element.type).toBe('div'); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('throws in render() if the mount callback is not a function', function() { diff --git a/src/renderers/dom/client/__tests__/ReactMount-test.js b/src/renderers/dom/client/__tests__/ReactMount-test.js index 96ca4aef3336b..b72a26dec551f 100644 --- a/src/renderers/dom/client/__tests__/ReactMount-test.js +++ b/src/renderers/dom/client/__tests__/ReactMount-test.js @@ -44,7 +44,7 @@ describe('ReactMount', function() { var nodeArray = document.getElementsByTagName('div'); expect(function() { ReactDOM.unmountComponentAtNode(nodeArray); - }).toThrow( + }).toThrowError( 'unmountComponentAtNode(...): Target container is not a DOM element.' ); }); @@ -53,7 +53,7 @@ describe('ReactMount', function() { it('throws when given a string', function() { expect(function() { ReactTestUtils.renderIntoDocument('div'); - }).toThrow( + }).toThrowError( 'ReactDOM.render(): Invalid component element. Instead of passing a ' + 'string like \'div\', pass React.createElement(\'div\') or
.' ); @@ -67,7 +67,7 @@ describe('ReactMount', function() { }); expect(function() { ReactTestUtils.renderIntoDocument(Component); - }).toThrow( + }).toThrowError( 'ReactDOM.render(): Invalid component element. Instead of passing a ' + 'class like Foo, pass React.createElement(Foo) or .' ); @@ -133,12 +133,12 @@ describe('ReactMount', function() { spyOn(console, 'error'); ReactMount.render(
, container); - expect(console.error.calls.length).toBe(1); + expect(console.error.calls.count()).toBe(1); container.innerHTML = ' ' + ReactDOMServer.renderToString(
); ReactMount.render(
, container); - expect(console.error.calls.length).toBe(2); + expect(console.error.calls.count()).toBe(2); }); it('should not warn if mounting into non-empty node', function() { @@ -147,7 +147,7 @@ describe('ReactMount', function() { spyOn(console, 'error'); ReactMount.render(
, container); - expect(console.error.calls.length).toBe(0); + expect(console.error.calls.count()).toBe(0); }); it('should warn when mounting into document.body', function() { @@ -157,8 +157,8 @@ describe('ReactMount', function() { ReactMount.render(
, iFrame.contentDocument.body); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'Rendering components directly into document.body is discouraged' ); }); @@ -174,8 +174,8 @@ describe('ReactMount', function() {
This markup contains an nbsp entity:   client text
, div ); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( ' (client) nbsp entity:   client text
\n' + ' (server) nbsp entity:   server text
' ); @@ -217,8 +217,8 @@ describe('ReactMount', function() { spyOn(console, 'error'); var rootNode = container.firstChild; ReactDOM.render(, rootNode); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: render(...): Replacing React-rendered children with a new ' + 'root component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state and ' + @@ -300,10 +300,10 @@ describe('ReactMount', function() { ReactTestUtils.renderIntoDocument(); - expect(console.time.argsForCall.length).toBe(1); - expect(console.time.argsForCall[0][0]).toBe('React mount: Foo'); - expect(console.timeEnd.argsForCall.length).toBe(1); - expect(console.timeEnd.argsForCall[0][0]).toBe('React mount: Foo'); + expect(console.time.calls.count()).toBe(1); + expect(console.time.calls.argsFor(0)[0]).toBe('React mount: Foo'); + expect(console.timeEnd.calls.count()).toBe(1); + expect(console.timeEnd.calls.argsFor(0)[0]).toBe('React mount: Foo'); } finally { ReactFeatureFlags.logTopLevelRenders = false; } diff --git a/src/renderers/dom/client/__tests__/ReactMountDestruction-test.js b/src/renderers/dom/client/__tests__/ReactMountDestruction-test.js index a4d8e39973101..c86d79bd44c48 100644 --- a/src/renderers/dom/client/__tests__/ReactMountDestruction-test.js +++ b/src/renderers/dom/client/__tests__/ReactMountDestruction-test.js @@ -53,8 +53,8 @@ describe('ReactMount', function() { var rootDiv = mainContainerDiv.firstChild; spyOn(console, 'error'); ReactDOM.unmountComponentAtNode(rootDiv); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: unmountComponentAtNode(): The node you\'re attempting to ' + 'unmount was rendered by React and is not a top-level container. You ' + 'may have accidentally passed in a React root node instead of its ' + @@ -77,8 +77,8 @@ describe('ReactMount', function() { var nonRootDiv = mainContainerDiv.firstChild.firstChild; spyOn(console, 'error'); ReactDOM.unmountComponentAtNode(nonRootDiv); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toBe( 'Warning: unmountComponentAtNode(): The node you\'re attempting to ' + 'unmount was rendered by React and is not a top-level container. ' + 'Instead, have the parent component update its state and rerender in ' + diff --git a/src/renderers/dom/client/__tests__/ReactRenderDocument-test.js b/src/renderers/dom/client/__tests__/ReactRenderDocument-test.js index 1d96826626c4c..6f2b5d3c2d763 100644 --- a/src/renderers/dom/client/__tests__/ReactRenderDocument-test.js +++ b/src/renderers/dom/client/__tests__/ReactRenderDocument-test.js @@ -94,7 +94,7 @@ describe('rendering React components at document', function() { expect(function() { ReactDOM.unmountComponentAtNode(testDocument); - }).toThrow(UNMOUNT_INVARIANT_MESSAGE); + }).toThrowError(UNMOUNT_INVARIANT_MESSAGE); expect(testDocument.body.innerHTML).toBe('Hello world'); }); @@ -142,7 +142,7 @@ describe('rendering React components at document', function() { // Reactive update expect(function() { ReactDOM.render(, testDocument); - }).toThrow(UNMOUNT_INVARIANT_MESSAGE); + }).toThrowError(UNMOUNT_INVARIANT_MESSAGE); expect(testDocument.body.innerHTML).toBe('Hello world'); }); @@ -201,7 +201,7 @@ describe('rendering React components at document', function() { expect(function() { // Notice the text is different! ReactDOM.render(, testDocument); - }).toThrow( + }).toThrowError( 'You\'re trying to render a component to the document using ' + 'server rendering but the checksum was invalid. This usually ' + 'means you rendered a different component type or props on ' + @@ -237,7 +237,7 @@ describe('rendering React components at document', function() { expect(function() { ReactDOM.render(, container); - }).toThrow( + }).toThrowError( 'You\'re trying to render a component to the document but you didn\'t ' + 'use server rendering. We can\'t do this without using server ' + 'rendering due to cross-browser quirks. See ' + diff --git a/src/renderers/dom/client/__tests__/findDOMNode-test.js b/src/renderers/dom/client/__tests__/findDOMNode-test.js index 1f861dd3454c5..185e67c516fd7 100644 --- a/src/renderers/dom/client/__tests__/findDOMNode-test.js +++ b/src/renderers/dom/client/__tests__/findDOMNode-test.js @@ -37,7 +37,7 @@ describe('findDOMNode', function() { it('findDOMNode should reject random objects', function() { expect(function() { ReactDOM.findDOMNode({foo: 'bar'}); - }).toThrow( + }).toThrowError( 'Element appears to be neither ReactComponent nor DOMNode (keys: foo)' ); }); @@ -53,7 +53,7 @@ describe('findDOMNode', function() { var inst = ReactDOM.render(, container); ReactDOM.unmountComponentAtNode(container); - expect(() => ReactDOM.findDOMNode(inst)).toThrow( + expect(() => ReactDOM.findDOMNode(inst)).toThrowError( 'findDOMNode was called on an unmounted component.' ); }); diff --git a/src/renderers/dom/client/syntheticEvents/__tests__/SyntheticEvent-test.js b/src/renderers/dom/client/syntheticEvents/__tests__/SyntheticEvent-test.js index a8799c8f87ad8..e4a7c8b8e82c1 100644 --- a/src/renderers/dom/client/syntheticEvents/__tests__/SyntheticEvent-test.js +++ b/src/renderers/dom/client/syntheticEvents/__tests__/SyntheticEvent-test.js @@ -87,9 +87,9 @@ describe('SyntheticEvent', function() { expect(syntheticEvent.nativeEvent).toBe(null); expect(syntheticEvent.target).toBe(null); // once for each property accessed - expect(console.error.calls.length).toBe(3); + expect(console.error.calls.count()).toBe(3); // assert the first warning for accessing `type` - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.argsFor(0)[0]).toBe( 'Warning: This synthetic event is reused for performance reasons. If ' + 'you\'re seeing this, you\'re accessing the property `type` on a ' + 'released/nullified synthetic event. This is set to null. If you must ' + @@ -104,8 +104,8 @@ describe('SyntheticEvent', function() { var syntheticEvent = createEvent({srcElement: target}); syntheticEvent.destructor(); expect(syntheticEvent.type = 'MouseEvent').toBe('MouseEvent'); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.argsFor(0)[0]).toBe( 'Warning: This synthetic event is reused for performance reasons. If ' + 'you\'re seeing this, you\'re setting the property `type` on a ' + 'released/nullified synthetic event. This is effectively a no-op. If you must ' + @@ -119,8 +119,8 @@ describe('SyntheticEvent', function() { var syntheticEvent = createEvent({}); SyntheticEvent.release(syntheticEvent); syntheticEvent.preventDefault(); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.argsFor(0)[0]).toBe( 'Warning: This synthetic event is reused for performance reasons. If ' + 'you\'re seeing this, you\'re accessing the method `preventDefault` on a ' + 'released/nullified synthetic event. This is a no-op function. If you must ' + @@ -134,8 +134,8 @@ describe('SyntheticEvent', function() { var syntheticEvent = createEvent({}); SyntheticEvent.release(syntheticEvent); syntheticEvent.stopPropagation(); - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.argsFor(0)[0]).toBe( 'Warning: This synthetic event is reused for performance reasons. If ' + 'you\'re seeing this, you\'re accessing the method `stopPropagation` on a ' + 'released/nullified synthetic event. This is a no-op function. If you must ' + @@ -156,13 +156,13 @@ describe('SyntheticEvent', function() { } var instance = ReactDOM.render(
, element); ReactTestUtils.Simulate.click(ReactDOM.findDOMNode(instance)); - expect(console.error.calls.length).toBe(0); + expect(console.error.calls.count()).toBe(0); // access a property to cause the warning event.nativeEvent; // eslint-disable-line no-unused-expressions - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.argsFor(0)[0]).toBe( 'Warning: This synthetic event is reused for performance reasons. If ' + 'you\'re seeing this, you\'re accessing the property `nativeEvent` on a ' + 'released/nullified synthetic event. This is set to null. If you must ' + @@ -178,15 +178,15 @@ describe('SyntheticEvent', function() { SyntheticEvent.release(syntheticEvent); expect(syntheticEvent.foo).toBe('bar'); if (typeof Proxy === 'function') { - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toBe( + expect(console.error.calls.count()).toBe(1); + expect(console.error.argsFor(0)[0]).toBe( 'Warning: This synthetic event is reused for performance reasons. If ' + 'you\'re seeing this, you\'re adding a new property in the synthetic ' + 'event object. The property is never released. ' + 'See https://fb.me/react-event-pooling for more information.' ); } else { - expect(console.error.calls.length).toBe(0); + expect(console.error.calls.count()).toBe(0); } }); }); diff --git a/src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js b/src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js index 7e68c03eb5393..090207f301c40 100644 --- a/src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js +++ b/src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js @@ -329,29 +329,29 @@ describe('ReactDOMInput', function() { it('should warn with value and no onChange handler', function() { var link = new ReactLink('yolo', jest.fn()); ReactTestUtils.renderIntoDocument(); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( '`valueLink` prop on `input` is deprecated; set `value` and `onChange` instead.' ); ReactTestUtils.renderIntoDocument( ); - expect(console.error.argsForCall.length).toBe(1); + expect(console.error.calls.count()).toBe(1); ReactTestUtils.renderIntoDocument(); - expect(console.error.argsForCall.length).toBe(2); + expect(console.error.calls.count()).toBe(2); }); it('should warn with value and no onChange handler and readOnly specified', function() { ReactTestUtils.renderIntoDocument( ); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); ReactTestUtils.renderIntoDocument( ); - expect(console.error.argsForCall.length).toBe(1); + expect(console.error.calls.count()).toBe(1); }); it('should have a this value of undefined if bind is not used', function() { @@ -407,8 +407,8 @@ describe('ReactDOMInput', function() { var node = document.createElement('div'); var link = new ReactLink(true, jest.fn()); ReactDOM.render(, node); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( '`checkedLink` prop on `input` is deprecated; set `value` and `onChange` instead.' ); @@ -419,27 +419,27 @@ describe('ReactDOMInput', function() { onChange={jest.fn()} /> ); - expect(console.error.argsForCall.length).toBe(1); + expect(console.error.calls.count()).toBe(1); ReactTestUtils.renderIntoDocument( ); - expect(console.error.argsForCall.length).toBe(1); + expect(console.error.calls.count()).toBe(1); ReactTestUtils.renderIntoDocument(); - expect(console.error.argsForCall.length).toBe(2); + expect(console.error.calls.count()).toBe(2); }); it('should warn with checked and no onChange handler with readOnly specified', function() { ReactTestUtils.renderIntoDocument( ); - expect(console.error.argsForCall.length).toBe(0); + expect(console.error.calls.count()).toBe(0); ReactTestUtils.renderIntoDocument( ); - expect(console.error.argsForCall.length).toBe(1); + expect(console.error.calls.count()).toBe(1); }); it('should throw if both checked and checkedLink are provided', function() { @@ -488,21 +488,21 @@ describe('ReactDOMInput', function() { it('should warn if value is null', function() { ReactTestUtils.renderIntoDocument(); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.argsFor(0)[0]).toContain( '`value` prop on `input` should not be null. ' + 'Consider using the empty string to clear the component or `undefined` ' + 'for uncontrolled components.' ); ReactTestUtils.renderIntoDocument(); - expect(console.error.argsForCall.length).toBe(1); + expect(console.error.calls.count()).toBe(1); }); it('should warn if checked and defaultChecked props are specified', function() { ReactTestUtils.renderIntoDocument( ); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.argsFor(0)[0]).toContain( 'A component contains an input of type radio with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + @@ -514,14 +514,14 @@ describe('ReactDOMInput', function() { ReactTestUtils.renderIntoDocument( ); - expect(console.error.argsForCall.length).toBe(1); + expect(console.error.calls.count()).toBe(1); }); it('should warn if value and defaultValue props are specified', function() { ReactTestUtils.renderIntoDocument( ); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.argsFor(0)[0]).toContain( 'A component contains an input of type text with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + @@ -533,7 +533,7 @@ describe('ReactDOMInput', function() { ReactTestUtils.renderIntoDocument( ); - expect(console.error.argsForCall.length).toBe(1); + expect(console.error.calls.count()).toBe(1); }); it('should warn if controlled input switches to uncontrolled', function() { @@ -541,8 +541,8 @@ describe('ReactDOMInput', function() { var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(, container); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'A component is changing a controlled input of type text to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + @@ -555,8 +555,8 @@ describe('ReactDOMInput', function() { var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(, container); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'A component is changing a controlled input of type text to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + @@ -569,8 +569,8 @@ describe('ReactDOMInput', function() { var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(, container); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'A component is changing an uncontrolled input of type text to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + @@ -583,8 +583,8 @@ describe('ReactDOMInput', function() { var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(, container); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'A component is changing a controlled input of type checkbox to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + @@ -597,8 +597,8 @@ describe('ReactDOMInput', function() { var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(, container); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'A component is changing a controlled input of type checkbox to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + @@ -611,8 +611,8 @@ describe('ReactDOMInput', function() { var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(, container); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'A component is changing an uncontrolled input of type checkbox to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + @@ -625,8 +625,8 @@ describe('ReactDOMInput', function() { var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(, container); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'A component is changing a controlled input of type radio to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + @@ -639,8 +639,8 @@ describe('ReactDOMInput', function() { var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(, container); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'A component is changing a controlled input of type radio to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + @@ -653,8 +653,8 @@ describe('ReactDOMInput', function() { var container = document.createElement('div'); ReactDOM.render(stub, container); ReactDOM.render(, container); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( 'A component is changing an uncontrolled input of type radio to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + @@ -668,7 +668,7 @@ describe('ReactDOMInput', function() { } var log = []; var originalCreateElement = document.createElement; - spyOn(document, 'createElement').andCallFake(function(type) { + spyOn(document, 'createElement').and.callFake(function(type) { var el = originalCreateElement.apply(this, arguments); if (type === 'input') { Object.defineProperty(el, 'value', { @@ -677,7 +677,7 @@ describe('ReactDOMInput', function() { log.push('set value'); }, }); - spyOn(el, 'setAttribute').andCallFake(function(name, value) { + spyOn(el, 'setAttribute').and.callFake(function(name, value) { log.push('set ' + name); }); } diff --git a/src/renderers/dom/client/wrappers/__tests__/ReactDOMOption-test.js b/src/renderers/dom/client/wrappers/__tests__/ReactDOMOption-test.js index 3f9bf1fbaac11..d82219a9c5a93 100644 --- a/src/renderers/dom/client/wrappers/__tests__/ReactDOMOption-test.js +++ b/src/renderers/dom/client/wrappers/__tests__/ReactDOMOption-test.js @@ -39,8 +39,8 @@ describe('ReactDOMOption', function() { expect(node.innerHTML).toBe('1 2'); ReactTestUtils.renderIntoDocument(