The library for web and native user interfaces.
Avoid some innocuous test warnings.
This reduces some console.warning spew from `grunt test` output.
Ben Newman committed
Jul 17, 2013 at 19:56 UTC
75ce576d3daec14fd0214e33904a288fa319426c
4 files changed
+25
-1
src/core/__tests__/ReactCompositeComponent-test.js
+4
@@ -134,6 +134,8 @@ describe('ReactCompositeComponent', function() {
134
});
135
136
it('should auto bind methods and values correctly', function() {
137
+ spyOn(console, 'warn');
138
+
139
var ComponentClass = React.createClass({
140
getInitialState: function() {
141
return {valueToReturn: 'hi'};
@@ -168,7 +170,9 @@ describe('ReactCompositeComponent', function() {
170
// Next, prove that once mounted, the scope is bound correctly to the actual
171
// component.
172
ReactTestUtils.renderIntoDocument(instance);
173
+ expect(console.warn.argsForCall.length).toBe(0);
174
var explicitlyBound = instance.methodToBeExplicitlyBound.bind(instance);
175
+ expect(console.warn.argsForCall.length).toBe(1);
176
var autoBound = instance.methodAutoBound;
177
var explicitlyNotBound = instance.methodExplicitlyNotBound;
178
src/core/__tests__/ReactInstanceHandles-test.js
+5
@@ -138,6 +138,9 @@ describe('ReactInstanceHandles', function() {
138
ReactID.getID(childNodeB)
139
)).toBe(childNodeB);
140
141
+ spyOn(console, 'error');
142
+ expect(console.error.argsForCall.length).toBe(0);
143
+
144
expect(function() {
145
ReactInstanceHandles.findComponentRoot(
146
parentNode,
@@ -148,6 +151,8 @@ describe('ReactInstanceHandles', function() {
151
'Unable to find element. This probably means the DOM was ' +
152
'unexpectedly mutated (e.g. by the browser).'
153
);
154
+
155
+ expect(console.error.argsForCall.length).toBe(1);
156
});
157
});
158
src/core/__tests__/refs-test.js
+5
-1
@@ -44,7 +44,11 @@ var ClickCounter = React.createClass({
44
var i;
45
for (i=0; i < this.state.count; i++) {
46
children.push(
47
- <div className="clickLogDiv" ref={"clickLog" + i} />
47
+ <div
48
+ className="clickLogDiv"
49
+ key={"clickLog" + i}
50
+ ref={"clickLog" + i}
51
+ />
52
);
53
}
54
return (
src/dom/components/__tests__/ReactDOMTextarea-test.js
+11
@@ -62,9 +62,12 @@ describe('ReactDOMTextarea', function() {
62
});
63
64
it('should treat children like `defaultValue`', function() {
65
+ spyOn(console, 'warn');
66
+
67
var stub = <textarea>giraffe</textarea>;
68
var node = renderTextarea(stub);
69
70
+ expect(console.warn.argsForCall.length).toBe(1);
71
expect(node.value).toBe('giraffe');
72
73
// Changing children should do nothing, it functions like `defaultValue`.
@@ -73,21 +76,29 @@ describe('ReactDOMTextarea', function() {
76
});
77
78
it('should allow numbers as children', function() {
79
+ spyOn(console, 'warn');
80
var node = renderTextarea(<textarea>{17}</textarea>);
81
+ expect(console.warn.argsForCall.length).toBe(1);
82
expect(node.value).toBe('17');
83
});
84
85
it("should throw with multiple or invalid children", function() {
86
+ spyOn(console, 'warn');
87
+
88
expect(function() {
89
ReactTestUtils.renderIntoDocument(
90
<textarea>{'hello'}{'there'}</textarea>
91
);
92
}).toThrow();
93
94
+ expect(console.warn.argsForCall.length).toBe(1);
95
+
96
expect(function() {
97
ReactTestUtils.renderIntoDocument(
98
<textarea><strong /></textarea>
99
);
100
}).toThrow();
101
+
102
+ expect(console.warn.argsForCall.length).toBe(2);
103
});
104
});