Consistently use calls[n].args[n] instead of argsForCall[n][n] for Jasmine spies

This commit is contained in:
Matias Singers
2015-10-11 15:56:34 +08:00
parent 01817c143c
commit f8f2be05ce
15 changed files with 81 additions and 81 deletions
+3 -3
View File
@@ -86,7 +86,7 @@ describe('ReactFragment', function() {
spyOn(console, 'error');
ReactFragment.create(null);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'React.addons.createFragment only accepts a single object.'
);
});
@@ -95,7 +95,7 @@ describe('ReactFragment', function() {
spyOn(console, 'error');
ReactFragment.create([]);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'React.addons.createFragment only accepts a single object.'
);
});
@@ -104,7 +104,7 @@ describe('ReactFragment', function() {
spyOn(console, 'error');
ReactFragment.create(<div />);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'React.addons.createFragment does not accept a ReactElement without a ' +
'wrapper object.'
);
@@ -379,7 +379,7 @@ describe('ReactClass-spec', function() {
instance.getDOMNode();
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'MyComponent.getDOMNode(...) is deprecated. Please use ' +
'ReactDOM.findDOMNode(instance) instead.'
);
@@ -258,7 +258,7 @@ describe('ReactElementClone', function() {
});
ReactTestUtils.renderIntoDocument(React.createElement(GrandParent));
expect(console.error.argsForCall.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: Failed propType: ' +
'Invalid prop `color` of type `number` supplied to `Component`, ' +
'expected `string`. Check the render method of `Parent`.'
@@ -239,7 +239,7 @@ describe('ReactElementValidator', function() {
},
});
ReactTestUtils.renderIntoDocument(React.createElement(ParentComp));
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: Failed propType: ' +
'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
'expected `string`. Check the render method of `ParentComp`.'
@@ -253,22 +253,22 @@ describe('ReactElementValidator', function() {
React.createElement(true);
React.createElement(123);
expect(console.error.calls.length).toBe(4);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[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.calls[1].args[0]).toBe(
expect(console.error.argsForCall[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.calls[2].args[0]).toBe(
expect(console.error.argsForCall[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.calls[3].args[0]).toBe(
expect(console.error.argsForCall[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).'
@@ -292,7 +292,7 @@ describe('ReactElementValidator', function() {
'but got: null. Check the render method of `ParentComp`.'
);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[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 ' +
@@ -316,7 +316,7 @@ describe('ReactElementValidator', function() {
ReactTestUtils.renderIntoDocument(React.createElement(Component));
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: Failed propType: ' +
'Required prop `prop` was not specified in `Component`.'
);
@@ -340,7 +340,7 @@ describe('ReactElementValidator', function() {
);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: Failed propType: ' +
'Required prop `prop` was not specified in `Component`.'
);
@@ -366,12 +366,12 @@ describe('ReactElementValidator', function() {
);
expect(console.error.calls.length).toBe(2);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: Failed propType: ' +
'Required prop `prop` was not specified in `Component`.'
);
expect(console.error.calls[1].args[0]).toBe(
expect(console.error.argsForCall[1][0]).toBe(
'Warning: Failed propType: ' +
'Invalid prop `prop` of type `number` supplied to ' +
'`Component`, expected `string`.'
@@ -402,7 +402,7 @@ describe('ReactElementValidator', function() {
);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[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 ' +
@@ -52,7 +52,7 @@ describe 'ReactCoffeeScriptClass', ->
ReactDOM.render React.createElement(Foo), container
).toThrow()
expect(console.error.calls.length).toBe(1)
expect(console.error.calls[0].args[0]).toContain('No `render` method found on the returned component instance')
expect(console.error.argsForCall[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
@@ -293,16 +293,16 @@ describe 'ReactCoffeeScriptClass', ->
expect(getInitialStateWasCalled).toBe false
expect(getDefaultPropsWasCalled).toBe false
expect(console.error.calls.length).toBe 4
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'getInitialState was defined on Foo, a plain JavaScript class.'
)
expect(console.error.calls[1].args[0]).toContain(
expect(console.error.argsForCall[1][0]).toContain(
'getDefaultProps was defined on Foo, a plain JavaScript class.'
)
expect(console.error.calls[2].args[0]).toContain(
expect(console.error.argsForCall[2][0]).toContain(
'propTypes was defined as an instance property on Foo.'
)
expect(console.error.calls[3].args[0]).toContain(
expect(console.error.argsForCall[3][0]).toContain(
'contextTypes was defined as an instance property on Foo.'
)
@@ -318,7 +318,7 @@ describe 'ReactCoffeeScriptClass', ->
test React.createElement(NamedComponent), 'SPAN', 'foo'
expect(console.error.calls.length).toBe 1
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[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.'
@@ -336,7 +336,7 @@ describe 'ReactCoffeeScriptClass', ->
test React.createElement(NamedComponent), 'SPAN', 'foo'
expect(console.error.calls.length).toBe 1
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: NamedComponent has a method called componentWillRecieveProps().
Did you mean componentWillReceiveProps()?'
)
@@ -351,19 +351,19 @@ describe 'ReactCoffeeScriptClass', ->
expect(-> instance.setProps name: 'bar').toThrow()
expect(-> instance.replaceProps name: 'bar').toThrow()
expect(console.error.calls.length).toBe 5
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'getDOMNode(...) is deprecated in plain JavaScript React classes'
)
expect(console.error.calls[1].args[0]).toContain(
expect(console.error.argsForCall[1][0]).toContain(
'replaceState(...) is deprecated in plain JavaScript React classes'
)
expect(console.error.calls[2].args[0]).toContain(
expect(console.error.argsForCall[2][0]).toContain(
'isMounted(...) is deprecated in plain JavaScript React classes'
)
expect(console.error.calls[3].args[0]).toContain(
expect(console.error.argsForCall[3][0]).toContain(
'setProps(...) is deprecated in plain JavaScript React classes'
)
expect(console.error.calls[4].args[0]).toContain(
expect(console.error.argsForCall[4][0]).toContain(
'replaceProps(...) is deprecated in plain JavaScript React classes'
)
@@ -62,7 +62,7 @@ describe('ReactES6Class', function() {
expect(() => ReactDOM.render(<Foo />, container)).toThrow();
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: Foo(...): No `render` method found on the returned component ' +
'instance: you may have forgotten to define `render`, returned ' +
'null/false from a stateless component, or tried to render an element ' +
@@ -343,16 +343,16 @@ describe('ReactES6Class', function() {
expect(getInitialStateWasCalled).toBe(false);
expect(getDefaultPropsWasCalled).toBe(false);
expect(console.error.calls.length).toBe(4);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'getInitialState was defined on Foo, a plain JavaScript class.'
);
expect(console.error.calls[1].args[0]).toContain(
expect(console.error.argsForCall[1][0]).toContain(
'getDefaultProps was defined on Foo, a plain JavaScript class.'
);
expect(console.error.calls[2].args[0]).toContain(
expect(console.error.argsForCall[2][0]).toContain(
'propTypes was defined as an instance property on Foo.'
);
expect(console.error.calls[3].args[0]).toContain(
expect(console.error.argsForCall[3][0]).toContain(
'contextTypes was defined as an instance property on Foo.'
);
});
@@ -371,7 +371,7 @@ describe('ReactES6Class', function() {
test(<NamedComponent />, 'SPAN', 'foo');
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: ' +
'NamedComponent has a method called componentShouldUpdate(). Did you ' +
'mean shouldComponentUpdate()? The name is phrased as a question ' +
@@ -393,7 +393,7 @@ describe('ReactES6Class', function() {
test(<NamedComponent />, 'SPAN', 'foo');
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: ' +
'NamedComponent has a method called componentWillRecieveProps(). Did ' +
'you mean componentWillReceiveProps()?'
@@ -409,20 +409,20 @@ describe('ReactES6Class', function() {
expect(() => instance.setProps({name: 'bar'})).toThrow();
expect(() => instance.replaceProps({name: 'bar'})).toThrow();
expect(console.error.calls.length).toBe(5);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'getDOMNode(...) is deprecated in plain JavaScript React classes. ' +
'Use ReactDOM.findDOMNode(component) instead.'
);
expect(console.error.calls[1].args[0]).toContain(
expect(console.error.argsForCall[1][0]).toContain(
'replaceState(...) is deprecated in plain JavaScript React classes'
);
expect(console.error.calls[2].args[0]).toContain(
expect(console.error.argsForCall[2][0]).toContain(
'isMounted(...) is deprecated in plain JavaScript React classes'
);
expect(console.error.calls[3].args[0]).toContain(
expect(console.error.argsForCall[3][0]).toContain(
'setProps(...) is deprecated in plain JavaScript React classes'
);
expect(console.error.calls[4].args[0]).toContain(
expect(console.error.argsForCall[4][0]).toContain(
'replaceProps(...) is deprecated in plain JavaScript React classes'
);
});
@@ -195,7 +195,7 @@ describe('ReactJSXElementValidator', function() {
}
}
ReactTestUtils.renderIntoDocument(<ParentComp />);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: Failed propType: ' +
'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
'expected `string`. Check the render method of `ParentComp`.'
@@ -214,19 +214,19 @@ describe('ReactJSXElementValidator', function() {
void <True />;
void <Num />;
expect(console.error.calls.length).toBe(4);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[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.calls[1].args[0]).toContain(
expect(console.error.argsForCall[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.calls[2].args[0]).toContain(
expect(console.error.argsForCall[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.calls[3].args[0]).toContain(
expect(console.error.argsForCall[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).'
);
@@ -242,7 +242,7 @@ describe('ReactJSXElementValidator', function() {
ReactTestUtils.renderIntoDocument(<RequiredPropComponent />);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: Failed propType: ' +
'Required prop `prop` was not specified in `RequiredPropComponent`.'
);
@@ -254,7 +254,7 @@ describe('ReactJSXElementValidator', function() {
ReactTestUtils.renderIntoDocument(<RequiredPropComponent prop={null} />);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: Failed propType: ' +
'Required prop `prop` was not specified in `RequiredPropComponent`.'
);
@@ -267,12 +267,12 @@ describe('ReactJSXElementValidator', function() {
ReactTestUtils.renderIntoDocument(<RequiredPropComponent prop={42} />);
expect(console.error.calls.length).toBe(2);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: Failed propType: ' +
'Required prop `prop` was not specified in `RequiredPropComponent`.'
);
expect(console.error.calls[1].args[0]).toBe(
expect(console.error.argsForCall[1][0]).toBe(
'Warning: Failed propType: ' +
'Invalid prop `prop` of type `number` supplied to ' +
'`RequiredPropComponent`, expected `string`.'
@@ -300,7 +300,7 @@ describe('ReactJSXElementValidator', function() {
};
ReactTestUtils.renderIntoDocument(<NullPropTypeComponent />);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'Invariant Violation: NullPropTypeComponent: prop type `prop` is ' +
'invalid; it must be a function, usually from React.PropTypes.'
);
@@ -318,7 +318,7 @@ describe('ReactJSXElementValidator', function() {
};
ReactTestUtils.renderIntoDocument(<NullContextTypeComponent />);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'Invariant Violation: NullContextTypeComponent: context type `prop` is ' +
'invalid; it must be a function, usually from React.PropTypes.'
);
@@ -336,7 +336,7 @@ describe('ReactJSXElementValidator', function() {
});
ReactTestUtils.renderIntoDocument(<GetDefaultPropsComponent />);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'getDefaultProps is only used on classic React.createClass definitions.' +
' Use a static property named `defaultProps` instead.'
);
@@ -153,7 +153,7 @@ describe('ReactMount', function() {
ReactMount.render(<div />, iFrame.contentDocument.body);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'Rendering components directly into document.body is discouraged'
);
});
@@ -170,7 +170,7 @@ describe('ReactMount', function() {
div
);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
' (client) nbsp entity: &nbsp; client text</div>\n' +
' (server) nbsp entity: &nbsp; server text</div>'
);
@@ -238,7 +238,7 @@ describe('ReactMount', function() {
var rootNode = container.firstChild;
ReactDOM.render(<span />, rootNode);
expect(console.error.calls.length).toBe(1);
expect(console.error.mostRecentCall.args[0]).toBe(
expect(console.error.argsForCall[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 ' +
@@ -54,7 +54,7 @@ describe('ReactMount', function() {
spyOn(console, 'error');
ReactDOM.unmountComponentAtNode(rootDiv);
expect(console.error.calls.length).toBe(1);
expect(console.error.mostRecentCall.args[0]).toBe(
expect(console.error.argsForCall[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 ' +
@@ -78,7 +78,7 @@ describe('ReactMount', function() {
spyOn(console, 'error');
ReactDOM.unmountComponentAtNode(nonRootDiv);
expect(console.error.calls.length).toBe(1);
expect(console.error.mostRecentCall.args[0]).toBe(
expect(console.error.argsForCall[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 ' +
@@ -39,7 +39,7 @@ describe('ReactDOMOption', function() {
expect(node.innerHTML).toBe('1 2');
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain('Only strings and numbers are supported as <option> children.');
expect(console.error.argsForCall[0][0]).toContain('Only strings and numbers are supported as <option> children.');
});
it('should warn when passing invalid children', function() {
@@ -48,7 +48,7 @@ describe('ReactDOMOption', function() {
stub = ReactTestUtils.renderIntoDocument(stub);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'Only strings and numbers are supported as <option> children.'
);
});
@@ -819,7 +819,7 @@ describe('ReactDOMComponent', function() {
spyOn(console, 'error');
ReactTestUtils.renderIntoDocument(<div onScroll={function() {}} />);
expect(console.error.calls.length).toBe(1);
expect(console.error.mostRecentCall.args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: This browser doesn\'t support the `onScroll` event'
);
});
@@ -859,7 +859,7 @@ describe('ReactDOMComponent', function() {
ReactTestUtils.renderIntoDocument(<div><tr /><tr /></div>);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: validateDOMNesting(...): <tr> cannot appear as a child of ' +
'<div>. See div > tr.'
);
@@ -871,7 +871,7 @@ describe('ReactDOMComponent', function() {
ReactDOM.render(<span><p /></span>, p);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: validateDOMNesting(...): <p> cannot appear as a descendant ' +
'of <p>. See p > ... > p.'
);
@@ -892,7 +892,7 @@ describe('ReactDOMComponent', function() {
ReactTestUtils.renderIntoDocument(<Foo />);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: validateDOMNesting(...): <tr> cannot appear as a child of ' +
'<table>. See Foo > table > Row > tr. Add a <tbody> to your code to ' +
'match the DOM tree generated by the browser.'
@@ -926,7 +926,7 @@ describe('ReactDOMComponent', function() {
});
ReactTestUtils.renderIntoDocument(<App1 />);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'See Viz1 > table > FancyRow > Row > tr.'
);
@@ -938,25 +938,25 @@ describe('ReactDOMComponent', function() {
});
ReactTestUtils.renderIntoDocument(<App2 />);
expect(console.error.calls.length).toBe(2);
expect(console.error.calls[1].args[0]).toContain(
expect(console.error.argsForCall[1][0]).toContain(
'See Viz2 > FancyTable > Table > table > FancyRow > Row > tr.'
);
ReactTestUtils.renderIntoDocument(<FancyTable><FancyRow /></FancyTable>);
expect(console.error.calls.length).toBe(3);
expect(console.error.calls[2].args[0]).toContain(
expect(console.error.argsForCall[2][0]).toContain(
'See FancyTable > Table > table > FancyRow > Row > tr.'
);
ReactTestUtils.renderIntoDocument(<table><FancyRow /></table>);
expect(console.error.calls.length).toBe(4);
expect(console.error.calls[3].args[0]).toContain(
expect(console.error.argsForCall[3][0]).toContain(
'See table > FancyRow > Row > tr.'
);
ReactTestUtils.renderIntoDocument(<FancyTable><tr /></FancyTable>);
expect(console.error.calls.length).toBe(5);
expect(console.error.calls[4].args[0]).toContain(
expect(console.error.argsForCall[4][0]).toContain(
'See FancyTable > Table > table > tr.'
);
@@ -967,7 +967,7 @@ describe('ReactDOMComponent', function() {
});
ReactTestUtils.renderIntoDocument(<Link><div><Link /></div></Link>);
expect(console.error.calls.length).toBe(6);
expect(console.error.calls[5].args[0]).toContain(
expect(console.error.argsForCall[5][0]).toContain(
'See Link > a > ... > Link > a.'
);
});
@@ -1002,27 +1002,27 @@ describe('ReactDOMComponent', function() {
expect(innerDiv.isMounted()).toBe(false);
expect(console.error.calls.length).toBe(5);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: ReactDOMComponent: Do not access .props of a DOM ' +
'node; instead, recreate the props as `render` did originally or ' +
'read the DOM properties/attributes directly from this node (e.g., ' +
'this.refs.box.className). This DOM node was rendered by `Animal`.'
);
expect(console.error.calls[1].args[0]).toBe(
expect(console.error.argsForCall[1][0]).toBe(
'Warning: ReactDOMComponent: Do not access .setState(), ' +
'.replaceState(), or .forceUpdate() of a DOM node. This is a no-op. ' +
'This DOM node was rendered by `Animal`.'
);
expect(console.error.calls[2].args[0]).toBe(
expect(console.error.argsForCall[2][0]).toBe(
'Warning: ReactDOMComponent: Do not access .getDOMNode() of a DOM ' +
'node; instead, use the node directly. This DOM node was ' +
'rendered by `Animal`.'
);
expect(console.error.calls[3].args[0]).toBe(
expect(console.error.argsForCall[3][0]).toBe(
'Warning: ReactDOMComponent: Do not access .isMounted() of a DOM ' +
'node. This DOM node was rendered by `Animal`.'
);
expect(console.error.calls[4].args[0]).toContain('isMounted');
expect(console.error.argsForCall[4][0]).toContain('isMounted');
});
it('handles legacy setProps and replaceProps', function() {
@@ -1038,11 +1038,11 @@ describe('ReactDOMComponent', function() {
expect(node.textContent).toBe('');
expect(console.error.calls.length).toBe(2);
expect(console.error.calls[0].args[0]).toBe(
expect(console.error.argsForCall[0][0]).toBe(
'Warning: ReactDOMComponent: Do not access .setProps() of a DOM node. ' +
'Instead, call ReactDOM.render again at the top level.'
);
expect(console.error.calls[1].args[0]).toBe(
expect(console.error.argsForCall[1][0]).toBe(
'Warning: ReactDOMComponent: Do not access .replaceProps() of a DOM ' +
'node. Instead, call ReactDOM.render again at the top level.'
);
@@ -284,7 +284,7 @@ describe('ReactComponent', function() {
instance.getDOMNode();
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'Potato.getDOMNode(...) is deprecated. Please use ' +
'ReactDOM.findDOMNode(instance) instead.'
);
@@ -1075,7 +1075,7 @@ describe('ReactCompositeComponent', function() {
ReactTestUtils.renderIntoDocument(<div><NotAComponent /></div>);
}).toThrow(); // has no method 'render'
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain(
expect(console.error.argsForCall[0][0]).toContain(
'NotAComponent(...): No `render` method found'
);
});
@@ -187,7 +187,7 @@ describe('ReactMultiChildText', function() {
['', 'foo', <div>{true}{<div />}{1.2}{''}</div>, 'foo'], ['', 'foo', <div />, 'foo'],
]);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain('Warning: Each child in an array or iterator should have a unique "key" prop.');
expect(console.error.argsForCall[0][0]).toContain('Warning: Each child in an array or iterator should have a unique "key" prop.');
});
it('should throw if rendering both HTML and children', function() {
@@ -82,7 +82,7 @@ describe('traverseAllChildren', function() {
);
expect(traverseContext.length).toEqual(1);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain('Warning: Each child in an array or iterator should have a unique "key" prop.');
expect(console.error.argsForCall[0][0]).toContain('Warning: Each child in an array or iterator should have a unique "key" prop.');
});
it('should be called for each child', function() {
@@ -326,7 +326,7 @@ describe('traverseAllChildren', function() {
);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toContain('Warning: Each child in an array or iterator should have a unique "key" prop.');
expect(console.error.argsForCall[0][0]).toContain('Warning: Each child in an array or iterator should have a unique "key" prop.');
});
it('should be called for each child in an iterable with keys', function() {