Replaced document.createElement with ReactTestUtils.renderIntoDocument where container was not subsequently utilized. Fixes #1250
Replaced document.createElement with ReactTestUtils.renderIntoDocument where container was not subsequently utilized. Fixes #1250
Jim committed
Nov 24, 2014 at 21:56 UTC
89fafad255ae7fb0b6cebd38255259356f03554a
7 files changed
+21
-32
src/addons/link/__tests__/LinkedStateMixin-test.js
+3
-2
@@ -17,11 +17,13 @@ describe('LinkedStateMixin', function() {
17
var LinkedStateMixin;
18
var React;
19
var ReactLink;
20
+ var ReactTestUtils;
21
22
beforeEach(function() {
23
LinkedStateMixin = require('LinkedStateMixin');
24
React = require('React');
25
ReactLink = require('ReactLink');
26
+ ReactTestUtils = require('ReactTestUtils');
27
});
28
29
it('should create a ReactLink for state', function() {
@@ -36,8 +38,7 @@ describe('LinkedStateMixin', function() {
38
return <span>value is {this.state.value}</span>;
39
}
40
});
39
- var container = document.createElement('div');
40
- var component = React.render(<Component />, container);
41
+ var component = ReactTestUtils.renderIntoDocument(<Component />);
42
var link = component.linkState('value');
43
expect(component.state.value).toBe('initial value');
44
expect(link.value).toBe('initial value');
src/browser/ui/__tests__/ReactEventListener-test.js
+3
-2
@@ -21,6 +21,7 @@ describe('ReactEventListener', function() {
21
22
var ReactMount;
23
var ReactEventListener;
24
+ var ReactTestUtils;
25
var handleTopLevel;
26
27
beforeEach(function() {
@@ -29,6 +30,7 @@ describe('ReactEventListener', function() {
30
31
ReactMount = require('ReactMount');
32
ReactEventListener = require('ReactEventListener');
33
+ ReactTestUtils = require('ReactTestUtils');
34
35
handleTopLevel = mocks.getMockFunction();
36
ReactEventListener._handleTopLevel = handleTopLevel;
@@ -158,7 +160,6 @@ describe('ReactEventListener', function() {
160
});
161
162
it('should not fire duplicate events for a React DOM tree', function() {
161
- var container = document.createElement('div');
163
var Wrapper = React.createClass({
164
165
getInner: function() {
@@ -172,7 +173,7 @@ describe('ReactEventListener', function() {
173
174
});
175
175
- var instance = ReactMount.render(<Wrapper />, container);
176
+ var instance = ReactTestUtils.renderIntoDocument(<Wrapper />);
177
178
var callback = ReactEventListener.dispatchEvent.bind(null, 'test');
179
callback({
src/browser/ui/dom/components/__tests__/ReactDOMInput-test.js
+2
-4
@@ -195,11 +195,10 @@ describe('ReactDOMInput', function() {
195
});
196
197
it('should support ReactLink', function() {
198
- var container = document.createElement('div');
198
var link = new ReactLink('yolo', mocks.getMockFunction());
199
var instance = <input type="text" valueLink={link} />;
200
202
- instance = React.render(instance, container);
201
+ instance = ReactTestUtils.renderIntoDocument(instance);
202
203
expect(instance.getDOMNode().value).toBe('yolo');
204
expect(link.value).toBe('yolo');
@@ -274,11 +273,10 @@ describe('ReactDOMInput', function() {
273
});
274
275
it('should support checkedLink', function() {
277
- var container = document.createElement('div');
276
var link = new ReactLink(true, mocks.getMockFunction());
277
var instance = <input type="checkbox" checkedLink={link} />;
278
281
- instance = React.render(instance, container);
279
+ instance = ReactTestUtils.renderIntoDocument(instance);
280
281
expect(instance.getDOMNode().checked).toBe(true);
282
expect(link.value).toBe(true);
src/core/__tests__/ReactComponentLifeCycle-test.js
+2
-4
@@ -440,10 +440,8 @@ describe('ReactComponentLifeCycle', function() {
440
}
441
});
442
443
- var container = document.createElement('div');
444
- var instance = React.render(
445
- <Component text="uno" tooltipText="one" />,
446
- container
443
+ var instance = ReactTestUtils.renderIntoDocument(
444
+ <Component text="uno" tooltipText="one" />
445
);
446
447
// Since `instance` is a root component, we can set its props. This also
src/core/__tests__/ReactIdentity-test.js
+4
-4
@@ -182,7 +182,7 @@ describe('ReactIdentity', function() {
182
183
expect(function() {
184
185
- React.render(<TestContainer />, document.createElement('div'));
185
+ ReactTestUtils.renderIntoDocument(<TestContainer />);
186
187
}).not.toThrow();
188
});
@@ -218,7 +218,7 @@ describe('ReactIdentity', function() {
218
219
expect(function() {
220
221
- React.render(<TestContainer />, document.createElement('div'));
221
+ ReactTestUtils.renderIntoDocument(<TestContainer />);
222
223
}).not.toThrow();
224
});
@@ -245,7 +245,7 @@ describe('ReactIdentity', function() {
245
246
expect(function() {
247
248
- React.render(<TestContainer />, document.createElement('div'));
248
+ ReactTestUtils.renderIntoDocument(<TestContainer />);
249
250
}).not.toThrow();
251
});
@@ -304,7 +304,7 @@ describe('ReactIdentity', function() {
304
</div>;
305
306
expect(function() {
307
- React.render(component, document.createElement('div'));
307
+ ReactTestUtils.renderIntoDocument(component);
308
}).not.toThrow();
309
});
310
src/core/__tests__/ReactMultiChildText-test.js
+4
-9
@@ -214,23 +214,18 @@ describe('ReactMultiChildText', function() {
214
});
215
216
it('should render between nested components and inline children', function() {
217
- var container = document.createElement('div');
218
- React.render(<div><h1><span /><span /></h1></div>, container);
217
+ ReactTestUtils.renderIntoDocument(<div><h1><span /><span /></h1></div>);
218
219
expect(function() {
221
- React.render(<div><h1>A</h1></div>, container);
220
+ ReactTestUtils.renderIntoDocument(<div><h1>A</h1></div>);
221
}).not.toThrow();
222
224
- React.render(<div><h1><span /><span /></h1></div>, container);
225
-
223
expect(function() {
227
- React.render(<div><h1>{['A']}</h1></div>, container);
224
+ ReactTestUtils.renderIntoDocument(<div><h1>{['A']}</h1></div>);
225
}).not.toThrow();
226
230
- React.render(<div><h1><span /><span /></h1></div>, container);
231
-
227
expect(function() {
233
- React.render(<div><h1>{['A', 'B']}</h1></div>, container);
228
+ ReactTestUtils.renderIntoDocument(<div><h1>{['A', 'B']}</h1></div>);
229
}).not.toThrow();
230
});
231
});
src/core/__tests__/ReactUpdates-test.js
+3
-7
@@ -798,8 +798,7 @@ describe('ReactUpdates', function() {
798
}
799
});
800
801
- var container = document.createElement('div');
802
- var component = React.render(<A />, container);
801
+ var component = ReactTestUtils.renderIntoDocument(<A />);
802
component.forceUpdate();
803
expect(callbackCount).toBe(2);
804
});
@@ -832,8 +831,7 @@ describe('ReactUpdates', function() {
831
}
832
});
833
835
- var container = document.createElement('div');
836
- var component = React.render(<A />, container);
834
+ var component = ReactTestUtils.renderIntoDocument(<A />);
835
component.setState({updates: 1});
836
expect(log).toEqual([
837
'render-0',
@@ -880,9 +878,7 @@ describe('ReactUpdates', function() {
878
}
879
});
880
883
- var container = document.createElement('div');
884
-
885
- var component = React.render(<A />, container);
881
+ var component = ReactTestUtils.renderIntoDocument(<A />);
882
883
ReactUpdates.batchedUpdates(function() {
884
// B will have scheduled an update but the batching should ensure that its