fix log spew from ReactDOMInput test
The prop validation threw a warning that either `onChange` or `readOnly` is required. Set the `onChange` where needed.
Jan Kassens committed
Apr 21, 2014 at 15:41 UTC
089146b2f8086e78ec94ed527306fb36efd67c30
1 file changed
+49
-14
src/browser/ui/dom/components/__tests__/ReactDOMInput-test.js
+49
-14
@@ -82,18 +82,18 @@ describe('ReactDOMInput', function() {
82
});
83
84
it('should allow setting `value` to `true`', function() {
85
- var stub = <input type="text" value="yolo" />;
85
+ var stub = <input type="text" value="yolo" onChange={emptyFunction} />;
86
stub = ReactTestUtils.renderIntoDocument(stub);
87
var node = stub.getDOMNode();
88
89
expect(node.value).toBe('yolo');
90
91
- stub.replaceProps({value: true});
91
+ stub.replaceProps({value: true, onChange: emptyFunction});
92
expect(node.value).toEqual('true');
93
});
94
95
it("should allow setting `value` to `false`", function() {
96
- var stub = <input type="text" value="yolo" />;
96
+ var stub = <input type="text" value="yolo" onChange={emptyFunction} />;
97
stub = ReactTestUtils.renderIntoDocument(stub);
98
var node = stub.getDOMNode();
99
@@ -104,7 +104,7 @@ describe('ReactDOMInput', function() {
104
});
105
106
it('should allow setting `value` to `objToString`', function() {
107
- var stub = <input type="text" value="foo" />;
107
+ var stub = <input type="text" value="foo" onChange={emptyFunction} />;
108
stub = ReactTestUtils.renderIntoDocument(stub);
109
var node = stub.getDOMNode();
110
@@ -116,12 +116,12 @@ describe('ReactDOMInput', function() {
116
}
117
};
118
119
- stub.replaceProps({value: objToString});
119
+ stub.replaceProps({value: objToString, onChange: emptyFunction});
120
expect(node.value).toEqual('foobar');
121
});
122
123
it('should properly control a value of number `0`', function() {
124
- var stub = <input type="text" value={0} />;
124
+ var stub = <input type="text" value={0} onChange={emptyFunction} />;
125
stub = ReactTestUtils.renderIntoDocument(stub);
126
var node = stub.getDOMNode();
127
@@ -145,11 +145,28 @@ describe('ReactDOMInput', function() {
145
render: function() {
146
return (
147
<div>
148
- <input ref="a" type="radio" name="fruit" checked={true} />A
149
- <input ref="b" type="radio" name="fruit" />B
148
+ <input
149
+ ref="a"
150
+ type="radio"
151
+ name="fruit"
152
+ checked={true}
153
+ onChange={emptyFunction}
154
+ />A
155
+ <input
156
+ ref="b"
157
+ type="radio"
158
+ name="fruit"
159
+ onChange={emptyFunction}
160
+ />B
161
162
<form>
152
- <input ref="c" type="radio" name="fruit" defaultChecked={true} />
163
+ <input
164
+ ref="c"
165
+ type="radio"
166
+ name="fruit"
167
+ defaultChecked={true}
168
+ onChange={emptyFunction}
169
+ />
170
</form>
171
</div>
172
);
@@ -246,7 +263,13 @@ describe('ReactDOMInput', function() {
263
264
expect(React.renderComponent.bind(React, instance, node)).not.toThrow();
265
249
- instance = <input type="text" valueLink={link} value="test" />;
266
+ instance =
267
+ <input
268
+ type="text"
269
+ valueLink={link}
270
+ value="test"
271
+ onChange={emptyFunction}
272
+ />;
273
expect(React.renderComponent.bind(React, instance, node)).toThrow();
274
275
instance = <input type="text" valueLink={link} onChange={emptyFunction} />;
@@ -283,7 +306,11 @@ describe('ReactDOMInput', function() {
306
expect(console.warn.mock.calls.length).toBe(0);
307
308
React.renderComponent(
286
- <input type="checkbox" checked="false" onChange={mocks.getMockFunction()} />,
309
+ <input
310
+ type="checkbox"
311
+ checked="false"
312
+ onChange={mocks.getMockFunction()}
313
+ />,
314
node
315
);
316
expect(console.warn.mock.calls.length).toBe(0);
@@ -319,10 +346,17 @@ describe('ReactDOMInput', function() {
346
347
expect(React.renderComponent.bind(React, instance, node)).not.toThrow();
348
322
- instance = <input type="checkbox" checkedLink={link} checked="false" />;
349
+ instance =
350
+ <input
351
+ type="checkbox"
352
+ checkedLink={link}
353
+ checked="false"
354
+ onChange={emptyFunction}
355
+ />;
356
expect(React.renderComponent.bind(React, instance, node)).toThrow();
357
325
- instance = <input type="checkbox" checkedLink={link} onChange={emptyFunction} />;
358
+ instance =
359
+ <input type="checkbox" checkedLink={link} onChange={emptyFunction} />;
360
expect(React.renderComponent.bind(React, instance, node)).toThrow();
361
362
});
@@ -342,7 +376,8 @@ describe('ReactDOMInput', function() {
376
instance = <input type="checkbox" valueLink={link} />;
377
expect(React.renderComponent.bind(React, instance, node)).not.toThrow();
378
345
- instance = <input type="checkbox" checkedLink={link} valueLink={emptyFunction} />;
379
+ instance =
380
+ <input type="checkbox" checkedLink={link} valueLink={emptyFunction} />;
381
expect(React.renderComponent.bind(React, instance, node)).toThrow();
382
});
383
});