mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Avoid some innocuous test warnings.
This reduces some console.warning spew from `grunt test` output.
This commit is contained in:
committed by
Paul O’Shannessy
parent
fa7cc57a6d
commit
75ce576d3d
@@ -134,6 +134,8 @@ describe('ReactCompositeComponent', function() {
|
||||
});
|
||||
|
||||
it('should auto bind methods and values correctly', function() {
|
||||
spyOn(console, 'warn');
|
||||
|
||||
var ComponentClass = React.createClass({
|
||||
getInitialState: function() {
|
||||
return {valueToReturn: 'hi'};
|
||||
@@ -168,7 +170,9 @@ describe('ReactCompositeComponent', function() {
|
||||
// Next, prove that once mounted, the scope is bound correctly to the actual
|
||||
// component.
|
||||
ReactTestUtils.renderIntoDocument(instance);
|
||||
expect(console.warn.argsForCall.length).toBe(0);
|
||||
var explicitlyBound = instance.methodToBeExplicitlyBound.bind(instance);
|
||||
expect(console.warn.argsForCall.length).toBe(1);
|
||||
var autoBound = instance.methodAutoBound;
|
||||
var explicitlyNotBound = instance.methodExplicitlyNotBound;
|
||||
|
||||
|
||||
@@ -138,6 +138,9 @@ describe('ReactInstanceHandles', function() {
|
||||
ReactID.getID(childNodeB)
|
||||
)).toBe(childNodeB);
|
||||
|
||||
spyOn(console, 'error');
|
||||
expect(console.error.argsForCall.length).toBe(0);
|
||||
|
||||
expect(function() {
|
||||
ReactInstanceHandles.findComponentRoot(
|
||||
parentNode,
|
||||
@@ -148,6 +151,8 @@ describe('ReactInstanceHandles', function() {
|
||||
'Unable to find element. This probably means the DOM was ' +
|
||||
'unexpectedly mutated (e.g. by the browser).'
|
||||
);
|
||||
|
||||
expect(console.error.argsForCall.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -44,7 +44,11 @@ var ClickCounter = React.createClass({
|
||||
var i;
|
||||
for (i=0; i < this.state.count; i++) {
|
||||
children.push(
|
||||
<div className="clickLogDiv" ref={"clickLog" + i} />
|
||||
<div
|
||||
className="clickLogDiv"
|
||||
key={"clickLog" + i}
|
||||
ref={"clickLog" + i}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
|
||||
@@ -62,9 +62,12 @@ describe('ReactDOMTextarea', function() {
|
||||
});
|
||||
|
||||
it('should treat children like `defaultValue`', function() {
|
||||
spyOn(console, 'warn');
|
||||
|
||||
var stub = <textarea>giraffe</textarea>;
|
||||
var node = renderTextarea(stub);
|
||||
|
||||
expect(console.warn.argsForCall.length).toBe(1);
|
||||
expect(node.value).toBe('giraffe');
|
||||
|
||||
// Changing children should do nothing, it functions like `defaultValue`.
|
||||
@@ -73,21 +76,29 @@ describe('ReactDOMTextarea', function() {
|
||||
});
|
||||
|
||||
it('should allow numbers as children', function() {
|
||||
spyOn(console, 'warn');
|
||||
var node = renderTextarea(<textarea>{17}</textarea>);
|
||||
expect(console.warn.argsForCall.length).toBe(1);
|
||||
expect(node.value).toBe('17');
|
||||
});
|
||||
|
||||
it("should throw with multiple or invalid children", function() {
|
||||
spyOn(console, 'warn');
|
||||
|
||||
expect(function() {
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<textarea>{'hello'}{'there'}</textarea>
|
||||
);
|
||||
}).toThrow();
|
||||
|
||||
expect(console.warn.argsForCall.length).toBe(1);
|
||||
|
||||
expect(function() {
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<textarea><strong /></textarea>
|
||||
);
|
||||
}).toThrow();
|
||||
|
||||
expect(console.warn.argsForCall.length).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user