@samitouri / QOS-React-2 / commits / 9adcff442a

Apply codemod for React -> ReactDOM split

Ran the codemod automatically then ran ``` codemod.py -m -d src '(var React\b[^\n]*;)\n\n(var ReactDOM)' '\1\n\2' ``` to clean up spacing of requires.

Ben Alpert committed Aug 10, 2015 at 15:24 UTC 9adcff442a56ea9cb1f9aa4575202e028cbe7782
45 files changed +585 -491
src/addons/__tests__/ReactFragment-test.js
+4 -2
@@ -12,12 +12,14 @@
12 'use strict';
13
14 var React;
15 +var ReactDOM;
16 var ReactFragment;
17
18 describe('ReactFragment', function() {
19
20 beforeEach(function() {
21 React = require('React');
22 + ReactDOM = require('ReactDOM');
23 ReactFragment = require('ReactFragment');
24 });
25
@@ -54,7 +56,7 @@ describe('ReactFragment', function() {
56 var element = <div>{[children]}</div>;
57 expect(console.error.calls.length).toBe(0);
58 var container = document.createElement('div');
57 - React.render(element, container);
59 + ReactDOM.render(element, container);
60 expect(console.error.calls.length).toBe(1);
61 expect(console.error.calls[0].args[0]).toContain(
62 'Any use of a keyed object'
@@ -78,7 +80,7 @@ describe('ReactFragment', function() {
80 }
81 expect(console.error.calls.length).toBe(0);
82 var container = document.createElement('div');
81 - React.render(<Foo />, container);
83 + ReactDOM.render(<Foo />, container);
84 expect(console.error.calls.length).toBe(1);
85 expect(console.error.calls[0].args[0]).toContain(
86 'Any use of a keyed object'
src/addons/transitions/ReactCSSTransitionGroupChild.js
+3 -2
@@ -13,6 +13,7 @@
13 'use strict';
14
15 var React = require('React');
16 +var ReactDOM = require('ReactDOM');
17
18 var CSSCore = require('CSSCore');
19 var ReactTransitionEvents = require('ReactTransitionEvents');
@@ -47,7 +48,7 @@ var ReactCSSTransitionGroupChild = React.createClass({
48 displayName: 'ReactCSSTransitionGroupChild',
49
50 transition: function(animationType, finishCallback) {
50 - var node = React.findDOMNode(this);
51 + var node = ReactDOM.findDOMNode(this);
52
53 if (!node) {
54 if (finishCallback) {
@@ -104,7 +105,7 @@ var ReactCSSTransitionGroupChild = React.createClass({
105 flushClassNameQueue: function() {
106 if (this.isMounted()) {
107 this.classNameQueue.forEach(
107 - CSSCore.addClass.bind(CSSCore, React.findDOMNode(this))
108 + CSSCore.addClass.bind(CSSCore, ReactDOM.findDOMNode(this))
109 );
110 }
111 this.classNameQueue.length = 0;
src/addons/transitions/__tests__/ReactCSSTransitionGroup-test.js
+35 -33
@@ -12,6 +12,7 @@
12 'use strict';
13
14 var React;
15 +var ReactDOM;
16 var ReactCSSTransitionGroup;
17
18 // Most of the real functionality is covered in other unit tests, this just
@@ -21,6 +22,7 @@ describe('ReactCSSTransitionGroup', function() {
22
23 beforeEach(function() {
24 React = require('React');
25 + ReactDOM = require('ReactDOM');
26 ReactCSSTransitionGroup = require('ReactCSSTransitionGroup');
27
28 container = document.createElement('div');
@@ -28,25 +30,25 @@ describe('ReactCSSTransitionGroup', function() {
30 });
31
32 it('should warn after time with no transitionend', function() {
31 - var a = React.render(
33 + var a = ReactDOM.render(
34 <ReactCSSTransitionGroup transitionName="yolo">
35 <span key="one" id="one" />
36 </ReactCSSTransitionGroup>,
37 container
38 );
37 - expect(React.findDOMNode(a).childNodes.length).toBe(1);
39 + expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1);
40
41 setTimeout.mock.calls.length = 0;
42
41 - React.render(
43 + ReactDOM.render(
44 <ReactCSSTransitionGroup transitionName="yolo">
45 <span key="two" id="two" />
46 </ReactCSSTransitionGroup>,
47 container
48 );
47 - expect(React.findDOMNode(a).childNodes.length).toBe(2);
48 - expect(React.findDOMNode(a).childNodes[0].id).toBe('two');
49 - expect(React.findDOMNode(a).childNodes[1].id).toBe('one');
49 + expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(2);
50 + expect(ReactDOM.findDOMNode(a).childNodes[0].id).toBe('two');
51 + expect(ReactDOM.findDOMNode(a).childNodes[1].id).toBe('one');
52
53 // For some reason jst is adding extra setTimeout()s and grunt test isn't,
54 // so we need to do this disgusting hack.
@@ -57,31 +59,31 @@ describe('ReactCSSTransitionGroup', function() {
59 }
60 }
61
60 - expect(React.findDOMNode(a).childNodes.length).toBe(2);
62 + expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(2);
63 expect(console.error.argsForCall.length).toBe(1);
64 });
65
66 it('should keep both sets of DOM nodes around', function() {
65 - var a = React.render(
67 + var a = ReactDOM.render(
68 <ReactCSSTransitionGroup transitionName="yolo">
69 <span key="one" id="one" />
70 </ReactCSSTransitionGroup>,
71 container
72 );
71 - expect(React.findDOMNode(a).childNodes.length).toBe(1);
72 - React.render(
73 + expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1);
74 + ReactDOM.render(
75 <ReactCSSTransitionGroup transitionName="yolo">
76 <span key="two" id="two" />
77 </ReactCSSTransitionGroup>,
78 container
79 );
78 - expect(React.findDOMNode(a).childNodes.length).toBe(2);
79 - expect(React.findDOMNode(a).childNodes[0].id).toBe('two');
80 - expect(React.findDOMNode(a).childNodes[1].id).toBe('one');
80 + expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(2);
81 + expect(ReactDOM.findDOMNode(a).childNodes[0].id).toBe('two');
82 + expect(ReactDOM.findDOMNode(a).childNodes[1].id).toBe('one');
83 });
84
85 it('should switch transitionLeave from false to true', function() {
84 - var a = React.render(
86 + var a = ReactDOM.render(
87 <ReactCSSTransitionGroup
88 transitionName="yolo"
89 transitionEnter={false}
@@ -90,8 +92,8 @@ describe('ReactCSSTransitionGroup', function() {
92 </ReactCSSTransitionGroup>,
93 container
94 );
93 - expect(React.findDOMNode(a).childNodes.length).toBe(1);
94 - React.render(
95 + expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1);
96 + ReactDOM.render(
97 <ReactCSSTransitionGroup
98 transitionName="yolo"
99 transitionEnter={false}
@@ -100,8 +102,8 @@ describe('ReactCSSTransitionGroup', function() {
102 </ReactCSSTransitionGroup>,
103 container
104 );
103 - expect(React.findDOMNode(a).childNodes.length).toBe(1);
104 - React.render(
105 + expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1);
106 + ReactDOM.render(
107 <ReactCSSTransitionGroup
108 transitionName="yolo"
109 transitionEnter={false}
@@ -110,20 +112,20 @@ describe('ReactCSSTransitionGroup', function() {
112 </ReactCSSTransitionGroup>,
113 container
114 );
113 - expect(React.findDOMNode(a).childNodes.length).toBe(2);
114 - expect(React.findDOMNode(a).childNodes[0].id).toBe('three');
115 - expect(React.findDOMNode(a).childNodes[1].id).toBe('two');
115 + expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(2);
116 + expect(ReactDOM.findDOMNode(a).childNodes[0].id).toBe('three');
117 + expect(ReactDOM.findDOMNode(a).childNodes[1].id).toBe('two');
118 });
119
120 it('should work with no children', function() {
119 - React.render(
121 + ReactDOM.render(
122 <ReactCSSTransitionGroup transitionName="yolo" />,
123 container
124 );
125 });
126
127 it('should work with a null child', function() {
126 - React.render(
128 + ReactDOM.render(
129 <ReactCSSTransitionGroup transitionName="yolo">
130 {[null]}
131 </ReactCSSTransitionGroup>,
@@ -132,14 +134,14 @@ describe('ReactCSSTransitionGroup', function() {
134 });
135
136 it('should transition from one to null', function() {
135 - var a = React.render(
137 + var a = ReactDOM.render(
138 <ReactCSSTransitionGroup transitionName="yolo">
139 <span key="one" id="one" />
140 </ReactCSSTransitionGroup>,
141 container
142 );
141 - expect(React.findDOMNode(a).childNodes.length).toBe(1);
142 - React.render(
143 + expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1);
144 + ReactDOM.render(
145 <ReactCSSTransitionGroup transitionName="yolo">
146 {null}
147 </ReactCSSTransitionGroup>,
@@ -147,26 +149,26 @@ describe('ReactCSSTransitionGroup', function() {
149 );
150 // (Here, we expect the original child to stick around but test that no
151 // exception is thrown)
150 - expect(React.findDOMNode(a).childNodes.length).toBe(1);
151 - expect(React.findDOMNode(a).childNodes[0].id).toBe('one');
152 + expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1);
153 + expect(ReactDOM.findDOMNode(a).childNodes[0].id).toBe('one');
154 });
155
156 it('should transition from false to one', function() {
155 - var a = React.render(
157 + var a = ReactDOM.render(
158 <ReactCSSTransitionGroup transitionName="yolo">
159 {false}
160 </ReactCSSTransitionGroup>,
161 container
162 );
161 - expect(React.findDOMNode(a).childNodes.length).toBe(0);
162 - React.render(
163 + expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(0);
164 + ReactDOM.render(
165 <ReactCSSTransitionGroup transitionName="yolo">
166 <span key="one" id="one" />
167 </ReactCSSTransitionGroup>,
168 container
169 );
168 - expect(React.findDOMNode(a).childNodes.length).toBe(1);
169 - expect(React.findDOMNode(a).childNodes[0].id).toBe('one');
170 + expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1);
171 + expect(ReactDOM.findDOMNode(a).childNodes[0].id).toBe('one');
172 });
173
174 });
src/addons/transitions/__tests__/ReactTransitionGroup-test.js
+6 -4
@@ -12,6 +12,7 @@
12 'use strict';
13
14 var React;
15 +var ReactDOM;
16 var ReactTransitionGroup;
17
18 // Most of the real functionality is covered in other unit tests, this just
@@ -21,6 +22,7 @@ describe('ReactTransitionGroup', function() {
22
23 beforeEach(function() {
24 React = require('React');
25 + ReactDOM = require('ReactDOM');
26 ReactTransitionGroup = require('ReactTransitionGroup');
27
28 container = document.createElement('div');
@@ -76,7 +78,7 @@ describe('ReactTransitionGroup', function() {
78 },
79 });
80
79 - var instance = React.render(<Component />, container);
81 + var instance = ReactDOM.render(<Component />, container);
82 expect(log).toEqual(['didMount', 'willAppear', 'didAppear']);
83
84 log = [];
@@ -133,7 +135,7 @@ describe('ReactTransitionGroup', function() {
135 },
136 });
137
136 - var instance = React.render(<Component />, container);
138 + var instance = ReactDOM.render(<Component />, container);
139 expect(log).toEqual(['didMount']);
140 instance.setState({count: 2});
141 expect(log).toEqual(['didMount', 'didMount', 'willEnter']);
@@ -193,7 +195,7 @@ describe('ReactTransitionGroup', function() {
195 },
196 });
197
196 - var instance = React.render(<Component />, container);
198 + var instance = ReactDOM.render(<Component />, container);
199 expect(log).toEqual(['didMount']);
200 instance.setState({count: 2});
201 expect(log).toEqual(['didMount', 'didMount', 'willEnter']);
@@ -250,7 +252,7 @@ describe('ReactTransitionGroup', function() {
252 },
253 });
254
253 - var instance = React.render(<Component />, container);
255 + var instance = ReactDOM.render(<Component />, container);
256 expect(log).toEqual(['didMount0']);
257 log = [];
258
src/isomorphic/classic/__tests__/ReactContextValidator-test.js
+4 -2
@@ -18,6 +18,7 @@
18 'use strict';
19
20 var React;
21 +var ReactDOM;
22 var ReactTestUtils;
23
24 var reactComponentExpect;
@@ -27,6 +28,7 @@ describe('ReactContextValidator', function() {
28 require('mock-modules').dumpCache();
29
30 React = require('React');
31 + ReactDOM = require('ReactDOM');
32 ReactTestUtils = require('ReactTestUtils');
33 reactComponentExpect = require('reactComponentExpect');
34
@@ -122,8 +124,8 @@ describe('ReactContextValidator', function() {
124 });
125
126 var container = document.createElement('div');
125 - React.render(<Parent foo="abc" />, container);
126 - React.render(<Parent foo="def" />, container);
127 + ReactDOM.render(<Parent foo="abc" />, container);
128 + ReactDOM.render(<Parent foo="def" />, container);
129 expect(actualComponentWillReceiveProps).toEqual({foo: 'def'});
130 expect(actualShouldComponentUpdate).toEqual({foo: 'def'});
131 expect(actualComponentWillUpdate).toEqual({foo: 'def'});
src/isomorphic/classic/class/__tests__/ReactClass-test.js
+4 -2
@@ -14,12 +14,14 @@
14 var mocks = require('mocks');
15
16 var React;
17 +var ReactDOM;
18 var ReactTestUtils;
19
20 describe('ReactClass-spec', function() {
21
22 beforeEach(function() {
23 React = require('React');
24 + ReactDOM = require('ReactDOM');
25 ReactTestUtils = require('ReactTestUtils');
26 spyOn(console, 'error');
27 });
@@ -311,7 +313,7 @@ describe('ReactClass-spec', function() {
313 });
314
315 var container = document.createElement('div');
314 - React.render(<Outer />, container);
316 + ReactDOM.render(<Outer />, container);
317 expect(container.firstChild.className).toBe('foo');
318 });
319
@@ -372,7 +374,7 @@ describe('ReactClass-spec', function() {
374 });
375
376 var container = document.createElement('div');
375 - var instance = React.render(<MyComponent />, container);
377 + var instance = ReactDOM.render(<MyComponent />, container);
378
379 instance.getDOMNode();
380
src/isomorphic/classic/element/__tests__/ReactElement-test.js
+8 -6
@@ -15,6 +15,7 @@
15 // classic JS without JSX.
16
17 var React;
18 +var ReactDOM;
19 var ReactTestUtils;
20
21 describe('ReactElement', function() {
@@ -24,6 +25,7 @@ describe('ReactElement', function() {
25 require('mock-modules').dumpCache();
26
27 React = require('React');
28 + ReactDOM = require('ReactDOM');
29 ReactTestUtils = require('ReactTestUtils');
30 ComponentClass = React.createClass({
31 render: function() {
@@ -220,13 +222,13 @@ describe('ReactElement', function() {
222 });
223
224 var container = document.createElement('div');
223 - var instance = React.render(
225 + var instance = ReactDOM.render(
226 React.createElement(Component, {fruit: 'mango'}),
227 container
228 );
229 expect(instance.props.fruit).toBe('mango');
230
229 - React.render(React.createElement(Component), container);
231 + ReactDOM.render(React.createElement(Component), container);
232 expect(instance.props.fruit).toBe('persimmon');
233 });
234
@@ -265,7 +267,7 @@ describe('ReactElement', function() {
267 },
268 });
269 var outer = ReactTestUtils.renderIntoDocument(<Outer color="orange" />);
268 - expect(React.findDOMNode(outer).className).toBe('moo');
270 + expect(ReactDOM.findDOMNode(outer).className).toBe('moo');
271 });
272
273 it('throws when adding a prop (in dev) after element creation', function() {
@@ -284,9 +286,9 @@ describe('ReactElement', function() {
286 return el;
287 },
288 });
287 - var outer = React.render(<Outer />, container);
288 - expect(React.findDOMNode(outer).textContent).toBe('meow');
289 - expect(React.findDOMNode(outer).className).toBe('');
289 + var outer = ReactDOM.render(<Outer />, container);
290 + expect(ReactDOM.findDOMNode(outer).textContent).toBe('meow');
291 + expect(ReactDOM.findDOMNode(outer).className).toBe('');
292 });
293
294 it('does not warn for NaN props', function() {
src/isomorphic/classic/element/__tests__/ReactElementClone-test.js
+4 -2
@@ -14,12 +14,14 @@
14 require('mock-modules');
15
16 var React;
17 +var ReactDOM;
18 var ReactTestUtils;
19
20 describe('ReactElementClone', function() {
21
22 beforeEach(function() {
23 React = require('React');
24 + ReactDOM = require('ReactDOM');
25 ReactTestUtils = require('ReactTestUtils');
26 });
27
@@ -39,7 +41,7 @@ describe('ReactElementClone', function() {
41 },
42 });
43 var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
42 - expect(React.findDOMNode(component).childNodes[0].className).toBe('xyz');
44 + expect(ReactDOM.findDOMNode(component).childNodes[0].className).toBe('xyz');
45 });
46
47 it('should clone a composite component with new props', function() {
@@ -63,7 +65,7 @@ describe('ReactElementClone', function() {
65 },
66 });
67 var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
66 - expect(React.findDOMNode(component).childNodes[0].className).toBe('xyz');
68 + expect(ReactDOM.findDOMNode(component).childNodes[0].className).toBe('xyz');
69 });
70
71 it('should keep the original ref if it is not overridden', function() {
src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js
+3 -1
@@ -15,6 +15,7 @@
15 // classic JS without JSX.
16
17 var React;
18 +var ReactDOM;
19 var ReactFragment;
20 var ReactTestUtils;
21
@@ -25,6 +26,7 @@ describe('ReactElementValidator', function() {
26 require('mock-modules').dumpCache();
27
28 React = require('React');
29 + ReactDOM = require('ReactDOM');
30 ReactFragment = require('ReactFragment');
31 ReactTestUtils = require('ReactTestUtils');
32 ComponentClass = React.createClass({
@@ -486,7 +488,7 @@ describe('ReactElementValidator', function() {
488 return <div />;
489 },
490 componentDidMount: function() {
489 - React.findDOMNode(this).appendChild(this.props.children);
491 + ReactDOM.findDOMNode(this).appendChild(this.props.children);
492 },
493 });
494
src/isomorphic/deprecated/__tests__/cloneWithProps-test.js
+4 -2
@@ -12,6 +12,7 @@
12 'use strict';
13
14 var React;
15 +var ReactDOM;
16 var ReactTestUtils;
17
18 var onlyChild;
@@ -23,6 +24,7 @@ describe('cloneWithProps', function() {
24 beforeEach(function() {
25 require('mock-modules').dumpCache();
26 React = require('React');
27 + ReactDOM = require('ReactDOM');
28 ReactTestUtils = require('ReactTestUtils');
29 onlyChild = require('onlyChild');
30 cloneWithProps = require('cloneWithProps');
@@ -65,7 +67,7 @@ describe('cloneWithProps', function() {
67 },
68 });
69 var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
68 - expect(React.findDOMNode(component).childNodes[0].className)
70 + expect(ReactDOM.findDOMNode(component).childNodes[0].className)
71 .toBe('xyz child');
72 });
73
@@ -92,7 +94,7 @@ describe('cloneWithProps', function() {
94 },
95 });
96 var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
95 - expect(React.findDOMNode(component).childNodes[0].className)
97 + expect(ReactDOM.findDOMNode(component).childNodes[0].className)
98 .toBe('xyz child');
99 });
100
src/isomorphic/modern/class/__tests__/ReactES6Class-test.js
+6 -4
@@ -12,6 +12,7 @@
12 'use strict';
13
14 var React;
15 +var ReactDOM;
16
17 describe('ReactES6Class', function() {
18
@@ -26,6 +27,7 @@ describe('ReactES6Class', function() {
27
28 beforeEach(function() {
29 React = require('React');
30 + ReactDOM = require('ReactDOM');
31 container = document.createElement('div');
32 attachedListener = null;
33 renderedName = null;
@@ -42,7 +44,7 @@ describe('ReactES6Class', function() {
44 });
45
46 function test(element, expectedTag, expectedClassName) {
45 - var instance = React.render(element, container);
47 + var instance = ReactDOM.render(element, container);
48 expect(container.firstChild).not.toBeNull();
49 expect(container.firstChild.tagName).toBe(expectedTag);
50 expect(container.firstChild.className).toBe(expectedClassName);
@@ -57,7 +59,7 @@ describe('ReactES6Class', function() {
59 it('throws if no render function is defined', function() {
60 spyOn(console, 'error');
61 class Foo extends React.Component { }
60 - expect(() => React.render(<Foo />, container)).toThrow();
62 + expect(() => ReactDOM.render(<Foo />, container)).toThrow();
63
64 expect(console.error.calls.length).toBe(1);
65 expect(console.error.calls[0].args[0]).toBe(
@@ -308,7 +310,7 @@ describe('ReactES6Class', function() {
310 'did-update', freeze({value: 'foo'}), {},
311 ]);
312 lifeCycles = []; // reset
311 - React.unmountComponentAtNode(container);
313 + ReactDOM.unmountComponentAtNode(container);
314 expect(lifeCycles).toEqual([
315 'will-unmount',
316 ]);
@@ -456,7 +458,7 @@ describe('ReactES6Class', function() {
458
459 it('supports drilling through to the DOM using findDOMNode', function() {
460 var instance = test(<Inner name="foo" />, 'DIV', 'foo');
459 - var node = React.findDOMNode(instance);
461 + var node = ReactDOM.findDOMNode(instance);
462 expect(node).toBe(container.firstChild);
463 });
464
src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js
+4 -2
@@ -12,6 +12,7 @@
12 'use strict';
13
14 var React;
15 +var ReactDOM;
16 var ReactTestUtils;
17
18 describe('ReactJSXElement', function() {
@@ -21,6 +22,7 @@ describe('ReactJSXElement', function() {
22 require('mock-modules').dumpCache();
23
24 React = require('React');
25 + ReactDOM = require('ReactDOM');
26 ReactTestUtils = require('ReactTestUtils');
27 Component = class {
28 render() {
@@ -161,13 +163,13 @@ describe('ReactJSXElement', function() {
163 Component.defaultProps = {fruit: 'persimmon'};
164
165 var container = document.createElement('div');
164 - var instance = React.render(
166 + var instance = ReactDOM.render(
167 <Component fruit="mango" />,
168 container
169 );
170 expect(instance.props.fruit).toBe('mango');
171
170 - React.render(<Component />, container);
172 + ReactDOM.render(<Component />, container);
173 expect(instance.props.fruit).toBe('persimmon');
174 });
175
src/renderers/dom/client/__tests__/ReactDOM-test.js
+5 -4
@@ -12,6 +12,7 @@
12 'use strict';
13
14 var React = require('React');
15 +var ReactDOM = require('ReactDOM');
16 var ReactTestUtils = require('ReactTestUtils');
17 var div = React.createFactory('div');
18
@@ -48,14 +49,14 @@ describe('ReactDOM', function() {
49 it('allows a DOM element to be used with a string', function() {
50 var element = React.createElement('div', {className: 'foo'});
51 var instance = ReactTestUtils.renderIntoDocument(element);
51 - expect(React.findDOMNode(instance).tagName).toBe('DIV');
52 + expect(ReactDOM.findDOMNode(instance).tagName).toBe('DIV');
53 });
54
55 it('should allow children to be passed as an argument', function() {
56 var argDiv = ReactTestUtils.renderIntoDocument(
57 div(null, 'child')
58 );
58 - var argNode = React.findDOMNode(argDiv);
59 + var argNode = ReactDOM.findDOMNode(argDiv);
60 expect(argNode.innerHTML).toBe('child');
61 });
62
@@ -63,7 +64,7 @@ describe('ReactDOM', function() {
64 var conflictDiv = ReactTestUtils.renderIntoDocument(
65 div({children: 'fakechild'}, 'child')
66 );
66 - var conflictNode = React.findDOMNode(conflictDiv);
67 + var conflictNode = ReactDOM.findDOMNode(conflictDiv);
68 expect(conflictNode.innerHTML).toBe('child');
69 });
70
@@ -105,7 +106,7 @@ describe('ReactDOM', function() {
106 <div key="theBird" className="bird" />,
107 </div>
108 );
108 - var root = React.findDOMNode(myDiv);
109 + var root = ReactDOM.findDOMNode(myDiv);
110 var dog = root.childNodes[0];
111 expect(dog.className).toBe('bigdog');
112 });
src/renderers/dom/client/__tests__/ReactDOMSVG-test.js
+3 -1
@@ -12,15 +12,17 @@
12 'use strict';
13
14 var React;
15 +var ReactDOMServer;
16
17 describe('ReactDOMSVG', function() {
18
19 beforeEach(function() {
20 React = require('React');
21 + ReactDOMServer = require('ReactDOMServer');
22 });
23
24 it('creates initial namespaced markup', function() {
23 - var markup = React.renderToString(
25 + var markup = ReactDOMServer.renderToString(
26 <svg>
27 <image xlinkHref="http://i.imgur.com/w7GCRPb.png" />
28 </svg>
src/renderers/dom/client/__tests__/ReactEventListener-test.js
+23 -19
@@ -19,6 +19,8 @@ var EVENT_TARGET_PARAM = 1;
19 describe('ReactEventListener', function() {
20 var React;
21
22 + var ReactDOM;
23 +
24 var ReactMount;
25 var ReactEventListener;
26 var ReactTestUtils;
@@ -28,6 +30,8 @@ describe('ReactEventListener', function() {
30 require('mock-modules').dumpCache();
31 React = require('React');
32
33 + ReactDOM = require('ReactDOM');
34 +
35 ReactMount = require('ReactMount');
36 ReactEventListener = require('ReactEventListener');
37 ReactTestUtils = require('ReactTestUtils');
@@ -47,8 +51,8 @@ describe('ReactEventListener', function() {
51 fromElement: otherNode,
52 target: otherNode,
53 srcElement: otherNode,
50 - toElement: React.findDOMNode(component),
51 - relatedTarget: React.findDOMNode(component),
54 + toElement: ReactDOM.findDOMNode(component),
55 + relatedTarget: ReactDOM.findDOMNode(component),
56 view: window,
57 path: [otherNode, otherNode],
58 },
@@ -65,19 +69,19 @@ describe('ReactEventListener', function() {
69 childControl = ReactMount.render(childControl, childContainer);
70 parentControl =
71 ReactMount.render(parentControl, parentContainer);
68 - React.findDOMNode(parentControl).appendChild(childContainer);
72 + ReactDOM.findDOMNode(parentControl).appendChild(childContainer);
73
74 var callback = ReactEventListener.dispatchEvent.bind(null, 'test');
75 callback({
72 - target: React.findDOMNode(childControl),
76 + target: ReactDOM.findDOMNode(childControl),
77 });
78
79 var calls = handleTopLevel.mock.calls;
80 expect(calls.length).toBe(2);
81 expect(calls[0][EVENT_TARGET_PARAM])
78 - .toBe(React.findDOMNode(childControl));
82 + .toBe(ReactDOM.findDOMNode(childControl));
83 expect(calls[1][EVENT_TARGET_PARAM])
80 - .toBe(React.findDOMNode(parentControl));
84 + .toBe(ReactDOM.findDOMNode(parentControl));
85 });
86
87 it('should propagate events two levels down', function() {
@@ -92,22 +96,22 @@ describe('ReactEventListener', function() {
96 ReactMount.render(parentControl, parentContainer);
97 grandParentControl =
98 ReactMount.render(grandParentControl, grandParentContainer);
95 - React.findDOMNode(parentControl).appendChild(childContainer);
96 - React.findDOMNode(grandParentControl).appendChild(parentContainer);
99 + ReactDOM.findDOMNode(parentControl).appendChild(childContainer);
100 + ReactDOM.findDOMNode(grandParentControl).appendChild(parentContainer);
101
102 var callback = ReactEventListener.dispatchEvent.bind(null, 'test');
103 callback({
100 - target: React.findDOMNode(childControl),
104 + target: ReactDOM.findDOMNode(childControl),
105 });
106
107 var calls = handleTopLevel.mock.calls;
108 expect(calls.length).toBe(3);
109 expect(calls[0][EVENT_TARGET_PARAM])
106 - .toBe(React.findDOMNode(childControl));
110 + .toBe(ReactDOM.findDOMNode(childControl));
111 expect(calls[1][EVENT_TARGET_PARAM])
108 - .toBe(React.findDOMNode(parentControl));
112 + .toBe(ReactDOM.findDOMNode(parentControl));
113 expect(calls[2][EVENT_TARGET_PARAM])
110 - .toBe(React.findDOMNode(grandParentControl));
114 + .toBe(ReactDOM.findDOMNode(grandParentControl));
115 });
116
117 it('should not get confused by disappearing elements', function() {
@@ -118,13 +122,13 @@ describe('ReactEventListener', function() {
122 childControl = ReactMount.render(childControl, childContainer);
123 parentControl =
124 ReactMount.render(parentControl, parentContainer);
121 - React.findDOMNode(parentControl).appendChild(childContainer);
125 + ReactDOM.findDOMNode(parentControl).appendChild(childContainer);
126
127 // ReactBrowserEventEmitter.handleTopLevel might remove the
128 // target from the DOM. Here, we have handleTopLevel remove the
129 // node when the first event handlers are called; we'll still
130 // expect to receive a second call for the parent control.
127 - var childNode = React.findDOMNode(childControl);
131 + var childNode = ReactDOM.findDOMNode(childControl);
132 handleTopLevel.mockImplementation(
133 function(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent) {
134 if (topLevelTarget === childNode) {
@@ -142,7 +146,7 @@ describe('ReactEventListener', function() {
146 expect(calls.length).toBe(2);
147 expect(calls[0][EVENT_TARGET_PARAM]).toBe(childNode);
148 expect(calls[1][EVENT_TARGET_PARAM])
145 - .toBe(React.findDOMNode(parentControl));
149 + .toBe(ReactDOM.findDOMNode(parentControl));
150 });
151
152 it('should batch between handlers from different roots', function() {
@@ -156,11 +160,11 @@ describe('ReactEventListener', function() {
160 <div>Parent</div>,
161 parentContainer
162 );
159 - React.findDOMNode(parentControl).appendChild(childContainer);
163 + ReactDOM.findDOMNode(parentControl).appendChild(childContainer);
164
165 // Suppose an event handler in each root enqueues an update to the
166 // childControl element -- the two updates should get batched together.
163 - var childNode = React.findDOMNode(childControl);
167 + var childNode = ReactDOM.findDOMNode(childControl);
168 handleTopLevel.mockImplementation(
169 function(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent) {
170 ReactMount.render(
@@ -202,12 +206,12 @@ describe('ReactEventListener', function() {
206
207 var callback = ReactEventListener.dispatchEvent.bind(null, 'test');
208 callback({
205 - target: React.findDOMNode(instance.getInner()),
209 + target: ReactDOM.findDOMNode(instance.getInner()),
210 });
211
212 var calls = handleTopLevel.mock.calls;
213 expect(calls.length).toBe(1);
214 expect(calls[0][EVENT_TARGET_PARAM])
211 - .toBe(React.findDOMNode(instance.getInner()));
215 + .toBe(ReactDOM.findDOMNode(instance.getInner()));
216 });
217 });
src/renderers/dom/client/__tests__/ReactMount-test.js
+12 -10
@@ -15,6 +15,8 @@ var mocks = require('mocks');
15
16 describe('ReactMount', function() {
17 var React = require('React');
18 + var ReactDOM = require('ReactDOM');
19 + var ReactDOMServer = require('ReactDOMServer');
20 var ReactMount = require('ReactMount');
21 var ReactTestUtils = require('ReactTestUtils');
22 var WebComponents = WebComponents;
@@ -33,7 +35,7 @@ describe('ReactMount', function() {
35 it('throws when given a non-node', function() {
36 var nodeArray = document.getElementsByTagName('div');
37 expect(function() {
36 - React.unmountComponentAtNode(nodeArray);
38 + ReactDOM.unmountComponentAtNode(nodeArray);
39 }).toThrow(
40 'Invariant Violation: unmountComponentAtNode(...): Target container ' +
41 'is not a DOM element.'
@@ -114,21 +116,21 @@ describe('ReactMount', function() {
116
117 it('should reuse markup if rendering to the same target twice', function() {
118 var container = document.createElement('container');
117 - var instance1 = React.render(<div />, container);
118 - var instance2 = React.render(<div />, container);
119 + var instance1 = ReactDOM.render(<div />, container);
120 + var instance2 = ReactDOM.render(<div />, container);
121
122 expect(instance1 === instance2).toBe(true);
123 });
124
125 it('should warn if mounting into dirty rendered markup', function() {
126 var container = document.createElement('container');
125 - container.innerHTML = React.renderToString(<div />) + ' ';
127 + container.innerHTML = ReactDOMServer.renderToString(<div />) + ' ';
128
129 spyOn(console, 'error');
130 ReactMount.render(<div />, container);
131 expect(console.error.calls.length).toBe(1);
132
131 - container.innerHTML = ' ' + React.renderToString(<div />);
133 + container.innerHTML = ' ' + ReactDOMServer.renderToString(<div />);
134
135 ReactMount.render(<div />, container);
136 expect(console.error.calls.length).toBe(2);
@@ -158,12 +160,12 @@ describe('ReactMount', function() {
160
161 it('should account for escaping on a checksum mismatch', function () {
162 var div = document.createElement('div');
161 - var markup = React.renderToString(
163 + var markup = ReactDOMServer.renderToString(
164 <div>This markup contains an nbsp entity: &nbsp; server text</div>);
165 div.innerHTML = markup;
166
167 spyOn(console, 'error');
166 - React.render(
168 + ReactDOM.render(
169 <div>This markup contains an nbsp entity: &nbsp; client text</div>,
170 div
171 );
@@ -182,15 +184,15 @@ describe('ReactMount', function() {
184 createdCallback: {
185 value: function() {
186 shadowRoot = this.createShadowRoot();
185 - React.render(<div>Hi, from within a WC!</div>, shadowRoot);
187 + ReactDOM.render(<div>Hi, from within a WC!</div>, shadowRoot);
188 expect(shadowRoot.firstChild.tagName).toBe('DIV');
187 - React.render(<span>Hi, from within a WC!</span>, shadowRoot);
189 + ReactDOM.render(<span>Hi, from within a WC!</span>, shadowRoot);
190 expect(shadowRoot.firstChild.tagName).toBe('SPAN');
191 },
192 },
193 });
194 proto.unmount = function() {
193 - React.unmountComponentAtNode(shadowRoot);
195 + ReactDOM.unmountComponentAtNode(shadowRoot);
196 };
197 document.registerElement('x-foo', {prototype: proto});
198 var element = document.createElement('x-foo');
src/renderers/dom/client/__tests__/ReactMountDestruction-test.js
+5 -4
@@ -12,6 +12,7 @@
12 'use strict';
13
14 var React = require('React');
15 +var ReactDOM = require('ReactDOM');
16
17 describe('ReactMount', function() {
18 it('should destroy a react root upon request', function() {
@@ -24,7 +25,7 @@ describe('ReactMount', function() {
25 );
26 var firstRootDiv = document.createElement('div');
27 mainContainerDiv.appendChild(firstRootDiv);
27 - React.render(instanceOne, firstRootDiv);
28 + ReactDOM.render(instanceOne, firstRootDiv);
29
30 var instanceTwo = (
31 <div className="secondReactDiv">
@@ -32,16 +33,16 @@ describe('ReactMount', function() {
33 );
34 var secondRootDiv = document.createElement('div');
35 mainContainerDiv.appendChild(secondRootDiv);
35 - React.render(instanceTwo, secondRootDiv);
36 + ReactDOM.render(instanceTwo, secondRootDiv);
37
38 // Test that two react roots are rendered in isolation
39 expect(firstRootDiv.firstChild.className).toBe('firstReactDiv');
40 expect(secondRootDiv.firstChild.className).toBe('secondReactDiv');
41
42 // Test that after unmounting each, they are no longer in the document.
42 - React.unmountComponentAtNode(firstRootDiv);
43 + ReactDOM.unmountComponentAtNode(firstRootDiv);
44 expect(firstRootDiv.firstChild).toBeNull();
44 - React.unmountComponentAtNode(secondRootDiv);
45 + ReactDOM.unmountComponentAtNode(secondRootDiv);
46 expect(secondRootDiv.firstChild).toBeNull();
47 });
48 });
src/renderers/dom/client/__tests__/ReactRenderDocument-test.js
+20 -16
@@ -12,6 +12,8 @@
12 'use strict';
13
14 var React;
15 +var ReactDOM;
16 +var ReactDOMServer;
17 var ReactInstanceMap;
18 var ReactMount;
19
@@ -31,6 +33,8 @@ describe('rendering React components at document', function() {
33 require('mock-modules').dumpCache();
34
35 React = require('React');
36 + ReactDOM = require('ReactDOM');
37 + ReactDOMServer = require('ReactDOMServer');
38 ReactInstanceMap = require('ReactInstanceMap');
39 ReactMount = require('ReactMount');
40 getTestDocument = require('getTestDocument');
@@ -56,9 +60,9 @@ describe('rendering React components at document', function() {
60 },
61 });
62
59 - var markup = React.renderToString(<Root />);
63 + var markup = ReactDOMServer.renderToString(<Root />);
64 testDocument = getTestDocument(markup);
61 - var component = React.render(<Root />, testDocument);
65 + var component = ReactDOM.render(<Root />, testDocument);
66 expect(testDocument.body.innerHTML).toBe('Hello world');
67
68 // TODO: This is a bad test. I have no idea what this is testing.
@@ -85,13 +89,13 @@ describe('rendering React components at document', function() {
89 },
90 });
91
88 - var markup = React.renderToString(<Root />);
92 + var markup = ReactDOMServer.renderToString(<Root />);
93 testDocument = getTestDocument(markup);
90 - React.render(<Root />, testDocument);
94 + ReactDOM.render(<Root />, testDocument);
95 expect(testDocument.body.innerHTML).toBe('Hello world');
96
97 expect(function() {
94 - React.unmountComponentAtNode(testDocument);
98 + ReactDOM.unmountComponentAtNode(testDocument);
99 }).toThrow(UNMOUNT_INVARIANT_MESSAGE);
100
101 expect(testDocument.body.innerHTML).toBe('Hello world');
@@ -130,16 +134,16 @@ describe('rendering React components at document', function() {
134 },
135 });
136
133 - var markup = React.renderToString(<Component />);
137 + var markup = ReactDOMServer.renderToString(<Component />);
138 testDocument = getTestDocument(markup);
139
136 - React.render(<Component />, testDocument);
140 + ReactDOM.render(<Component />, testDocument);
141
142 expect(testDocument.body.innerHTML).toBe('Hello world');
143
144 // Reactive update
145 expect(function() {
142 - React.render(<Component2 />, testDocument);
146 + ReactDOM.render(<Component2 />, testDocument);
147 }).toThrow(UNMOUNT_INVARIANT_MESSAGE);
148
149 expect(testDocument.body.innerHTML).toBe('Hello world');
@@ -163,12 +167,12 @@ describe('rendering React components at document', function() {
167 },
168 });
169
166 - var markup = React.renderToString(
170 + var markup = ReactDOMServer.renderToString(
171 <Component text="Hello world" />
172 );
173 testDocument = getTestDocument(markup);
174
171 - React.render(<Component text="Hello world" />, testDocument);
175 + ReactDOM.render(<Component text="Hello world" />, testDocument);
176
177 expect(testDocument.body.innerHTML).toBe('Hello world');
178 });
@@ -191,14 +195,14 @@ describe('rendering React components at document', function() {
195 },
196 });
197
194 - var markup = React.renderToString(
198 + var markup = ReactDOMServer.renderToString(
199 <Component text="Goodbye world" />
200 );
201 testDocument = getTestDocument(markup);
202
203 expect(function() {
204 // Notice the text is different!
201 - React.render(<Component text="Hello world" />, testDocument);
205 + ReactDOM.render(<Component text="Hello world" />, testDocument);
206 }).toThrow(
207 'Invariant Violation: ' +
208 'You\'re trying to render a component to the document using ' +
@@ -235,7 +239,7 @@ describe('rendering React components at document', function() {
239 });
240
241 expect(function() {
238 - React.render(<Component />, container);
242 + ReactDOM.render(<Component />, container);
243 }).toThrow(
244 'Invariant Violation: You\'re trying to render a component to the ' +
245 'document but you didn\'t use server rendering. We can\'t do this ' +
@@ -255,10 +259,10 @@ describe('rendering React components at document', function() {
259 </body>
260 </html>;
261
258 - var markup = React.renderToString(tree);
262 + var markup = ReactDOMServer.renderToString(tree);
263 testDocument = getTestDocument(markup);
260 - var component = React.render(tree, testDocument);
264 + var component = ReactDOM.render(tree, testDocument);
265 expect(testDocument.body.innerHTML).toBe('Hello world');
262 - expect(React.findDOMNode(component).tagName).toBe('HTML');
266 + expect(ReactDOM.findDOMNode(component).tagName).toBe('HTML');
267 });
268 });
src/renderers/dom/client/__tests__/findDOMNode-test.js
+6 -5
@@ -12,11 +12,12 @@
12 'use strict';
13
14 var React = require('React');
15 +var ReactDOM = require('ReactDOM');
16 var ReactTestUtils = require('ReactTestUtils');
17
18 describe('findDOMNode', function() {
19 it('findDOMNode should return null if passed null', function() {
19 - expect(React.findDOMNode(null)).toBe(null);
20 + expect(ReactDOM.findDOMNode(null)).toBe(null);
21 });
22
23 it('findDOMNode should find dom element', function() {
@@ -27,15 +28,15 @@ describe('findDOMNode', function() {
28 });
29
30 var myNode = ReactTestUtils.renderIntoDocument(<MyNode />);
30 - var myDiv = React.findDOMNode(myNode);
31 - var mySameDiv = React.findDOMNode(myDiv);
31 + var myDiv = ReactDOM.findDOMNode(myNode);
32 + var mySameDiv = ReactDOM.findDOMNode(myDiv);
33 expect(myDiv.tagName).toBe('DIV');
34 expect(mySameDiv).toBe(myDiv);
35 });
36
37 it('findDOMNode should reject random objects', function() {
38 expect(function() {
38 - React.findDOMNode({foo: 'bar'});
39 + ReactDOM.findDOMNode({foo: 'bar'});
40 })
41 .toThrow('Invariant Violation: Element appears to be neither ' +
42 'ReactComponent nor DOMNode (keys: foo)'
@@ -44,7 +45,7 @@ describe('findDOMNode', function() {
45
46 it('findDOMNode should reject unmounted objects with render func', function() {
47 expect(function() {
47 - React.findDOMNode({render: function() {}});
48 + ReactDOM.findDOMNode({render: function() {}});
49 })
50 .toThrow('Invariant Violation: Component (with keys: render) ' +
51 'contains `render` method but is not mounted in the DOM'
src/renderers/dom/client/eventPlugins/__tests__/EnterLeaveEventPlugin-test.js
+4 -2
@@ -14,6 +14,7 @@
14 var EnterLeaveEventPlugin;
15 var EventConstants;
16 var React;
17 +var ReactDOM;
18 var ReactMount;
19
20 var topLevelTypes;
@@ -25,6 +26,7 @@ describe('EnterLeaveEventPlugin', function() {
26 EnterLeaveEventPlugin = require('EnterLeaveEventPlugin');
27 EventConstants = require('EventConstants');
28 React = require('React');
29 + ReactDOM = require('ReactDOM');
30 ReactMount = require('ReactMount');
31
32 topLevelTypes = EventConstants.topLevelTypes;
@@ -41,8 +43,8 @@ describe('EnterLeaveEventPlugin', function() {
43 );
44 iframeDocument.close();
45
44 - var component = React.render(<div />, iframeDocument.body.getElementsByTagName('div')[0]);
45 - var div = React.findDOMNode(component);
46 + var component = ReactDOM.render(<div />, iframeDocument.body.getElementsByTagName('div')[0]);
47 + var div = ReactDOM.findDOMNode(component);
48
49 var extracted = EnterLeaveEventPlugin.extractEvents(
50 topLevelTypes.topMouseOver,
src/renderers/dom/client/eventPlugins/__tests__/SelectEventPlugin-test.js
+4 -2
@@ -13,6 +13,7 @@
13
14 var EventConstants;
15 var React;
16 +var ReactDOM;
17 var ReactMount;
18 var ReactTestUtils;
19 var SelectEventPlugin;
@@ -33,6 +34,7 @@ describe('SelectEventPlugin', function() {
34 beforeEach(function() {
35 EventConstants = require('EventConstants');
36 React = require('React');
37 + ReactDOM = require('ReactDOM');
38 ReactMount = require('ReactMount');
39 ReactTestUtils = require('ReactTestUtils');
40 SelectEventPlugin = require('SelectEventPlugin');
@@ -48,7 +50,7 @@ describe('SelectEventPlugin', function() {
50 });
51
52 var rendered = ReactTestUtils.renderIntoDocument(<WithoutSelect />);
51 - var node = React.findDOMNode(rendered);
53 + var node = ReactDOM.findDOMNode(rendered);
54 node.focus();
55
56 var mousedown = extract(node, topLevelTypes.topMouseDown);
@@ -72,7 +74,7 @@ describe('SelectEventPlugin', function() {
74 var rendered = ReactTestUtils.renderIntoDocument(
75 <WithSelect onSelect={cb} />
76 );
75 - var node = React.findDOMNode(rendered);
77 + var node = ReactDOM.findDOMNode(rendered);
78
79 node.selectionStart = 0;
80 node.selectionEnd = 0;
src/renderers/dom/client/wrappers/__tests__/ReactDOMButton-test.js
+10 -8
@@ -16,19 +16,20 @@ var mocks = require('mocks');
16
17 describe('ReactDOMButton', function() {
18 var React;
19 + var ReactDOM;
20 var ReactTestUtils;
21
22 var onClick = mocks.getMockFunction();
23
24 function expectClickThru(button) {
25 onClick.mockClear();
25 - ReactTestUtils.Simulate.click(React.findDOMNode(button));
26 + ReactTestUtils.Simulate.click(ReactDOM.findDOMNode(button));
27 expect(onClick.mock.calls.length).toBe(1);
28 }
29
30 function expectNoClickThru(button) {
31 onClick.mockClear();
31 - ReactTestUtils.Simulate.click(React.findDOMNode(button));
32 + ReactTestUtils.Simulate.click(ReactDOM.findDOMNode(button));
33 expect(onClick.mock.calls.length).toBe(0);
34 }
35
@@ -39,6 +40,7 @@ describe('ReactDOMButton', function() {
40
41 beforeEach(function() {
42 React = require('React');
43 + ReactDOM = require('ReactDOM');
44 ReactTestUtils = require('ReactTestUtils');
45 });
46
@@ -54,11 +56,11 @@ describe('ReactDOMButton', function() {
56
57 it('should forward clicks when it becomes not disabled', function() {
58 var container = document.createElement('div');
57 - var btn = React.render(
59 + var btn = ReactDOM.render(
60 <button disabled={true} onClick={onClick} />,
61 container
62 );
61 - btn = React.render(
63 + btn = ReactDOM.render(
64 <button onClick={onClick} />,
65 container
66 );
@@ -67,11 +69,11 @@ describe('ReactDOMButton', function() {
69
70 it('should not forward clicks when it becomes disabled', function() {
71 var container = document.createElement('div');
70 - var btn = React.render(
72 + var btn = ReactDOM.render(
73 <button onClick={onClick} />,
74 container
75 );
74 - btn = React.render(
76 + btn = ReactDOM.render(
77 <button disabled={true} onClick={onClick} />,
78 container
79 );
@@ -80,11 +82,11 @@ describe('ReactDOMButton', function() {
82
83 it('should work correctly if the listener is changed', function() {
84 var container = document.createElement('div');
83 - var btn = React.render(
85 + var btn = ReactDOM.render(
86 <button disabled={true} onClick={function() {}} />,
87 container
88 );
87 - btn = React.render(
89 + btn = ReactDOM.render(
90 <button disabled={false} onClick={onClick} />,
91 container
92 );
src/renderers/dom/client/wrappers/__tests__/ReactDOMIframe-test.js
+3 -1
@@ -13,10 +13,12 @@
13
14 describe('ReactDOMIframe', function() {
15 var React;
16 + var ReactDOM;
17 var ReactTestUtils;
18
19 beforeEach(function() {
20 React = require('React');
21 + ReactDOM = require('ReactDOM');
22 ReactTestUtils = require('ReactTestUtils');
23 });
24
@@ -28,7 +30,7 @@ describe('ReactDOMIframe', function() {
30 var loadEvent = document.createEvent('Event');
31 loadEvent.initEvent('load', false, false);
32
31 - React.findDOMNode(iframe).dispatchEvent(loadEvent);
33 + ReactDOM.findDOMNode(iframe).dispatchEvent(loadEvent);
34
35 expect(onLoadSpy).toHaveBeenCalled();
36 });
src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js
+38 -36
@@ -18,6 +18,7 @@ var mocks = require('mocks');
18 describe('ReactDOMInput', function() {
19 var EventConstants;
20 var React;
21 + var ReactDOM;
22 var ReactLink;
23 var ReactTestUtils;
24
@@ -25,6 +26,7 @@ describe('ReactDOMInput', function() {
26 require('mock-modules').dumpCache();
27 EventConstants = require('EventConstants');
28 React = require('React');
29 + ReactDOM = require('ReactDOM');
30 ReactLink = require('ReactLink');
31 ReactTestUtils = require('ReactTestUtils');
32 spyOn(console, 'error');
@@ -33,7 +35,7 @@ describe('ReactDOMInput', function() {
35 it('should display `defaultValue` of number 0', function() {
36 var stub = <input type="text" defaultValue={0} />;
37 stub = ReactTestUtils.renderIntoDocument(stub);
36 - var node = React.findDOMNode(stub);
38 + var node = ReactDOM.findDOMNode(stub);
39
40 expect(node.value).toBe('0');
41 });
@@ -41,7 +43,7 @@ describe('ReactDOMInput', function() {
43 it('should display "true" for `defaultValue` of `true`', function() {
44 var stub = <input type="text" defaultValue={true} />;
45 stub = ReactTestUtils.renderIntoDocument(stub);
44 - var node = React.findDOMNode(stub);
46 + var node = ReactDOM.findDOMNode(stub);
47
48 expect(node.value).toBe('true');
49 });
@@ -49,7 +51,7 @@ describe('ReactDOMInput', function() {
51 it('should display "false" for `defaultValue` of `false`', function() {
52 var stub = <input type="text" defaultValue={false} />;
53 stub = ReactTestUtils.renderIntoDocument(stub);
52 - var node = React.findDOMNode(stub);
54 + var node = ReactDOM.findDOMNode(stub);
55
56 expect(node.value).toBe('false');
57 });
@@ -63,7 +65,7 @@ describe('ReactDOMInput', function() {
65
66 var stub = <input type="text" defaultValue={objToString} />;
67 stub = ReactTestUtils.renderIntoDocument(stub);
66 - var node = React.findDOMNode(stub);
68 + var node = ReactDOM.findDOMNode(stub);
69
70 expect(node.value).toBe('foobar');
71 });
@@ -71,7 +73,7 @@ describe('ReactDOMInput', function() {
73 it('should display `value` of number 0', function() {
74 var stub = <input type="text" value={0} />;
75 stub = ReactTestUtils.renderIntoDocument(stub);
74 - var node = React.findDOMNode(stub);
76 + var node = ReactDOM.findDOMNode(stub);
77
78 expect(node.value).toBe('0');
79 });
@@ -79,12 +81,12 @@ describe('ReactDOMInput', function() {
81 it('should allow setting `value` to `true`', function() {
82 var container = document.createElement('div');
83 var stub = <input type="text" value="yolo" onChange={emptyFunction} />;
82 - stub = React.render(stub, container);
83 - var node = React.findDOMNode(stub);
84 + stub = ReactDOM.render(stub, container);
85 + var node = ReactDOM.findDOMNode(stub);
86
87 expect(node.value).toBe('yolo');
88
87 - stub = React.render(
89 + stub = ReactDOM.render(
90 <input type="text" value={true} onChange={emptyFunction} />,
91 container
92 );
@@ -94,12 +96,12 @@ describe('ReactDOMInput', function() {
96 it('should allow setting `value` to `false`', function() {
97 var container = document.createElement('div');
98 var stub = <input type="text" value="yolo" onChange={emptyFunction} />;
97 - stub = React.render(stub, container);
98 - var node = React.findDOMNode(stub);
99 + stub = ReactDOM.render(stub, container);
100 + var node = ReactDOM.findDOMNode(stub);
101
102 expect(node.value).toBe('yolo');
103
102 - stub = React.render(
104 + stub = ReactDOM.render(
105 <input type="text" value={false} onChange={emptyFunction} />,
106 container
107 );
@@ -109,8 +111,8 @@ describe('ReactDOMInput', function() {
111 it('should allow setting `value` to `objToString`', function() {
112 var container = document.createElement('div');
113 var stub = <input type="text" value="foo" onChange={emptyFunction} />;
112 - stub = React.render(stub, container);
113 - var node = React.findDOMNode(stub);
114 + stub = ReactDOM.render(stub, container);
115 + var node = ReactDOM.findDOMNode(stub);
116
117 expect(node.value).toBe('foo');
118
@@ -119,7 +121,7 @@ describe('ReactDOMInput', function() {
121 return 'foobar';
122 },
123 };
122 - stub = React.render(
124 + stub = ReactDOM.render(
125 <input type="text" value={objToString} onChange={emptyFunction} />,
126 container
127 );
@@ -129,7 +131,7 @@ describe('ReactDOMInput', function() {
131 it('should properly control a value of number `0`', function() {
132 var stub = <input type="text" value={0} onChange={emptyFunction} />;
133 stub = ReactTestUtils.renderIntoDocument(stub);
132 - var node = React.findDOMNode(stub);
134 + var node = ReactDOM.findDOMNode(stub);
135
136 node.value = 'giraffe';
137 ReactTestUtils.Simulate.change(node);
@@ -144,7 +146,7 @@ describe('ReactDOMInput', function() {
146 };
147 var stub = <input type="text" value={0} onChange={handler} />;
148 var container = document.createElement('div');
147 - var node = React.render(stub, container);
149 + var node = ReactDOM.render(stub, container);
150
151 node.value = 'giraffe';
152
@@ -163,7 +165,7 @@ describe('ReactDOMInput', function() {
165 it('should not set a value for submit buttons unnecessarily', function() {
166 var stub = <input type="submit" />;
167 stub = ReactTestUtils.renderIntoDocument(stub);
166 - var node = React.findDOMNode(stub);
168 + var node = ReactDOM.findDOMNode(stub);
169
170 // The value shouldn't be '', or else the button will have no text; it
171 // should have the default "Submit" or "Submit Query" label. Most browsers
@@ -208,9 +210,9 @@ describe('ReactDOMInput', function() {
210 });
211
212 var stub = ReactTestUtils.renderIntoDocument(<RadioGroup />);
211 - var aNode = React.findDOMNode(stub.refs.a);
212 - var bNode = React.findDOMNode(stub.refs.b);
213 - var cNode = React.findDOMNode(stub.refs.c);
213 + var aNode = ReactDOM.findDOMNode(stub.refs.a);
214 + var bNode = ReactDOM.findDOMNode(stub.refs.b);
215 + var cNode = ReactDOM.findDOMNode(stub.refs.c);
216
217 expect(aNode.checked).toBe(true);
218 expect(bNode.checked).toBe(false);
@@ -238,12 +240,12 @@ describe('ReactDOMInput', function() {
240
241 instance = ReactTestUtils.renderIntoDocument(instance);
242
241 - expect(React.findDOMNode(instance).value).toBe('yolo');
243 + expect(ReactDOM.findDOMNode(instance).value).toBe('yolo');
244 expect(link.value).toBe('yolo');
245 expect(link.requestChange.mock.calls.length).toBe(0);
246
245 - React.findDOMNode(instance).value = 'test';
246 - ReactTestUtils.Simulate.change(React.findDOMNode(instance));
247 + ReactDOM.findDOMNode(instance).value = 'test';
248 + ReactTestUtils.Simulate.change(ReactDOM.findDOMNode(instance));
249
250 expect(link.requestChange.mock.calls.length).toBe(1);
251 expect(link.requestChange.mock.calls[0][0]).toEqual('test');
@@ -279,7 +281,7 @@ describe('ReactDOMInput', function() {
281 var link = new ReactLink('yolo', mocks.getMockFunction());
282 var instance = <input type="text" valueLink={link} />;
283
282 - expect(() => React.render(instance, node)).not.toThrow();
284 + expect(() => ReactDOM.render(instance, node)).not.toThrow();
285
286 instance =
287 <input
@@ -288,10 +290,10 @@ describe('ReactDOMInput', function() {
290 value="test"
291 onChange={emptyFunction}
292 />;
291 - expect(() => React.render(instance, node)).toThrow();
293 + expect(() => ReactDOM.render(instance, node)).toThrow();
294
295 instance = <input type="text" valueLink={link} onChange={emptyFunction} />;
294 - expect(() => React.render(instance, node)).toThrow();
296 + expect(() => ReactDOM.render(instance, node)).toThrow();
297
298 });
299
@@ -301,12 +303,12 @@ describe('ReactDOMInput', function() {
303
304 instance = ReactTestUtils.renderIntoDocument(instance);
305
304 - expect(React.findDOMNode(instance).checked).toBe(true);
306 + expect(ReactDOM.findDOMNode(instance).checked).toBe(true);
307 expect(link.value).toBe(true);
308 expect(link.requestChange.mock.calls.length).toBe(0);
309
308 - React.findDOMNode(instance).checked = false;
309 - ReactTestUtils.Simulate.change(React.findDOMNode(instance));
310 + ReactDOM.findDOMNode(instance).checked = false;
311 + ReactTestUtils.Simulate.change(ReactDOM.findDOMNode(instance));
312
313 expect(link.requestChange.mock.calls.length).toBe(1);
314 expect(link.requestChange.mock.calls[0][0]).toEqual(false);
@@ -315,7 +317,7 @@ describe('ReactDOMInput', function() {
317 it('should warn with checked and no onChange handler', function() {
318 var node = document.createElement('div');
319 var link = new ReactLink(true, mocks.getMockFunction());
318 - React.render(<input type="checkbox" checkedLink={link} />, node);
320 + ReactDOM.render(<input type="checkbox" checkedLink={link} />, node);
321 expect(console.error.argsForCall.length).toBe(0);
322
323 ReactTestUtils.renderIntoDocument(
@@ -353,7 +355,7 @@ describe('ReactDOMInput', function() {
355 var link = new ReactLink(true, mocks.getMockFunction());
356 var instance = <input type="checkbox" checkedLink={link} />;
357
356 - expect(() => React.render(instance, node)).not.toThrow();
358 + expect(() => ReactDOM.render(instance, node)).not.toThrow();
359
360 instance =
361 <input
@@ -362,11 +364,11 @@ describe('ReactDOMInput', function() {
364 checked="false"
365 onChange={emptyFunction}
366 />;
365 - expect(() => React.render(instance, node)).toThrow();
367 + expect(() => ReactDOM.render(instance, node)).toThrow();
368
369 instance =
370 <input type="checkbox" checkedLink={link} onChange={emptyFunction} />;
369 - expect(() => React.render(instance, node)).toThrow();
371 + expect(() => ReactDOM.render(instance, node)).toThrow();
372
373 });
374
@@ -375,13 +377,13 @@ describe('ReactDOMInput', function() {
377 var link = new ReactLink(true, mocks.getMockFunction());
378 var instance = <input type="checkbox" checkedLink={link} />;
379
378 - expect(() => React.render(instance, node)).not.toThrow();
380 + expect(() => ReactDOM.render(instance, node)).not.toThrow();
381
382 instance = <input type="checkbox" valueLink={link} />;
381 - expect(() => React.render(instance, node)).not.toThrow();
383 + expect(() => ReactDOM.render(instance, node)).not.toThrow();
384
385 instance =
386 <input type="checkbox" checkedLink={link} valueLink={emptyFunction} />;
385 - expect(() => React.render(instance, node)).toThrow();
387 + expect(() => ReactDOM.render(instance, node)).toThrow();
388 });
389 });
src/renderers/dom/client/wrappers/__tests__/ReactDOMOption-test.js
+5 -4
@@ -14,17 +14,19 @@
14
15 describe('ReactDOMOption', function() {
16 var React;
17 + var ReactDOM;
18 var ReactTestUtils;
19
20 beforeEach(function() {
21 React = require('React');
22 + ReactDOM = require('ReactDOM');
23 ReactTestUtils = require('ReactTestUtils');
24 });
25
26 it('should flatten children to a string', function() {
27 var stub = <option>{1} {'foo'}</option>;
28 stub = ReactTestUtils.renderIntoDocument(stub);
27 - var node = React.findDOMNode(stub);
29 + var node = ReactDOM.findDOMNode(stub);
30
31 expect(node.innerHTML).toBe('1 foo');
32 });
@@ -33,7 +35,7 @@ describe('ReactDOMOption', function() {
35 spyOn(console, 'error');
36 var stub = <option>{1} <div /> {2}</option>;
37 stub = ReactTestUtils.renderIntoDocument(stub);
36 - var node = React.findDOMNode(stub);
38 + var node = ReactDOM.findDOMNode(stub);
39
40 expect(node.innerHTML).toBe('1 2');
41 expect(console.error.calls.length).toBe(1);
@@ -56,10 +58,9 @@ describe('ReactDOMOption', function() {
58 spyOn(console, 'error');
59 stub = ReactTestUtils.renderIntoDocument(stub);
60
59 - var node = React.findDOMNode(stub);
61 + var node = ReactDOM.findDOMNode(stub);
62
63 expect(console.error.calls.length).toBe(0);
64 expect(node.innerHTML).toBe('1 2');
65 });
64 -
66 });
src/renderers/dom/client/wrappers/__tests__/ReactDOMSelect-test.js
+47 -43
@@ -16,6 +16,8 @@ var mocks = require('mocks');
16
17 describe('ReactDOMSelect', function() {
18 var React;
19 + var ReactDOM;
20 + var ReactDOMServer;
21 var ReactLink;
22 var ReactTestUtils;
23
@@ -23,6 +25,8 @@ describe('ReactDOMSelect', function() {
25
26 beforeEach(function() {
27 React = require('React');
28 + ReactDOM = require('ReactDOM');
29 + ReactDOMServer = require('ReactDOMServer');
30 ReactLink = require('ReactLink');
31 ReactTestUtils = require('ReactTestUtils');
32 });
@@ -36,13 +40,13 @@ describe('ReactDOMSelect', function() {
40 </select>;
41 var options = stub.props.children;
42 var container = document.createElement('div');
39 - stub = React.render(stub, container);
40 - var node = React.findDOMNode(stub);
43 + stub = ReactDOM.render(stub, container);
44 + var node = ReactDOM.findDOMNode(stub);
45
46 expect(node.value).toBe('giraffe');
47
48 // Changing `defaultValue` should do nothing.
45 - React.render(
49 + ReactDOM.render(
50 <select defaultValue="gorilla">{options}</select>,
51 container
52 );
@@ -65,13 +69,13 @@ describe('ReactDOMSelect', function() {
69 <option value="gorilla">A gorilla!</option>
70 </select>;
71 var container = document.createElement('div');
68 - var stub = React.render(el, container);
69 - var node = React.findDOMNode(stub);
72 + var stub = ReactDOM.render(el, container);
73 + var node = ReactDOM.findDOMNode(stub);
74
75 expect(node.value).toBe('giraffe');
76
77 node.value = 'monkey';
74 - React.render(el, container);
78 + ReactDOM.render(el, container);
79 // Uncontrolled selects shouldn't change the value after first mounting
80 expect(node.value).toEqual('monkey');
81 });
@@ -85,15 +89,15 @@ describe('ReactDOMSelect', function() {
89 </select>;
90 var options = stub.props.children;
91 var container = document.createElement('div');
88 - stub = React.render(stub, container);
89 - var node = React.findDOMNode(stub);
92 + stub = ReactDOM.render(stub, container);
93 + var node = ReactDOM.findDOMNode(stub);
94
95 expect(node.options[0].selected).toBe(false); // monkey
96 expect(node.options[1].selected).toBe(true); // giraffe
97 expect(node.options[2].selected).toBe(true); // gorilla
98
99 // Changing `defaultValue` should do nothing.
96 - React.render(
100 + ReactDOM.render(
101 <select multiple={true} defaultValue={['monkey']}>{options}</select>,
102 container
103 );
@@ -112,13 +116,13 @@ describe('ReactDOMSelect', function() {
116 </select>;
117 var options = stub.props.children;
118 var container = document.createElement('div');
115 - stub = React.render(stub, container);
116 - var node = React.findDOMNode(stub);
119 + stub = ReactDOM.render(stub, container);
120 + var node = ReactDOM.findDOMNode(stub);
121
122 expect(node.value).toBe('giraffe');
123
124 // Changing the `value` prop should change the selected option.
121 - React.render(
125 + ReactDOM.render(
126 <select value="gorilla" onChange={noop}>{options}</select>,
127 container
128 );
@@ -142,15 +146,15 @@ describe('ReactDOMSelect', function() {
146 </select>;
147 var options = stub.props.children;
148 var container = document.createElement('div');
145 - stub = React.render(stub, container);
146 - var node = React.findDOMNode(stub);
149 + stub = ReactDOM.render(stub, container);
150 + var node = ReactDOM.findDOMNode(stub);
151
152 expect(node.options[0].selected).toBe(false); // monkey
153 expect(node.options[1].selected).toBe(true); // giraffe
154 expect(node.options[2].selected).toBe(true); // gorilla
155
156 // Changing the `value` prop should change the selected options.
153 - React.render(
157 + ReactDOM.render(
158 <select multiple={true} value={['monkey']} onChange={noop}>
159 {options}
160 </select>,
@@ -170,7 +174,7 @@ describe('ReactDOMSelect', function() {
174 <option value="12">twelve</option>
175 </select>;
176 stub = ReactTestUtils.renderIntoDocument(stub);
173 - var node = React.findDOMNode(stub);
177 + var node = ReactDOM.findDOMNode(stub);
178
179 expect(node.options[0].selected).toBe(false); // one
180 expect(node.options[1].selected).toBe(false); // two
@@ -180,9 +184,9 @@ describe('ReactDOMSelect', function() {
184 it('should reset child options selected when they are changed and `value` is set', function() {
185 var stub = <select multiple={true} value={['a', 'b']} onChange={noop} />;
186 var container = document.createElement('div');
183 - stub = React.render(stub, container);
187 + stub = ReactDOM.render(stub, container);
188
185 - React.render(
189 + ReactDOM.render(
190 <select multiple={true} value={['a', 'b']} onChange={noop}>
191 <option value="a">a</option>
192 <option value="b">b</option>
@@ -191,7 +195,7 @@ describe('ReactDOMSelect', function() {
195 container
196 );
197
194 - var node = React.findDOMNode(stub);
198 + var node = ReactDOM.findDOMNode(stub);
199
200 expect(node.options[0].selected).toBe(true); // a
201 expect(node.options[1].selected).toBe(true); // b
@@ -213,8 +217,8 @@ describe('ReactDOMSelect', function() {
217 <option value="gorilla">A gorilla!</option>
218 </select>;
219 var container = document.createElement('div');
216 - var stub = React.render(el, container);
217 - var node = React.findDOMNode(stub);
220 + var stub = ReactDOM.render(el, container);
221 + var node = ReactDOM.findDOMNode(stub);
222
223 expect(node.options[0].selected).toBe(false); // monkey
224 expect(node.options[1].selected).toBe(true); // giraffe
@@ -222,7 +226,7 @@ describe('ReactDOMSelect', function() {
226
227 // Changing the `value` prop should change the selected options.
228 objectToString.animal = 'monkey';
225 - React.render(el, container);
229 + ReactDOM.render(el, container);
230
231 expect(node.options[0].selected).toBe(true); // monkey
232 expect(node.options[1].selected).toBe(false); // giraffe
@@ -238,15 +242,15 @@ describe('ReactDOMSelect', function() {
242 </select>;
243 var options = stub.props.children;
244 var container = document.createElement('div');
241 - stub = React.render(stub, container);
242 - var node = React.findDOMNode(stub);
245 + stub = ReactDOM.render(stub, container);
246 + var node = ReactDOM.findDOMNode(stub);
247
248 expect(node.options[0].selected).toBe(false); // monkey
249 expect(node.options[1].selected).toBe(true); // giraffe
250 expect(node.options[2].selected).toBe(false); // gorilla
251
252 // When making it multiple, giraffe and gorilla should be selected
249 - React.render(
253 + ReactDOM.render(
254 <select multiple={true} defaultValue={['giraffe', 'gorilla']}>
255 {options}
256 </select>,
@@ -267,8 +271,8 @@ describe('ReactDOMSelect', function() {
271 </select>;
272 var options = stub.props.children;
273 var container = document.createElement('div');
270 - stub = React.render(stub, container);
271 - var node = React.findDOMNode(stub);
274 + stub = ReactDOM.render(stub, container);
275 + var node = ReactDOM.findDOMNode(stub);
276
277 expect(node.options[0].selected).toBe(false); // monkey
278 expect(node.options[1].selected).toBe(true); // giraffe
@@ -276,7 +280,7 @@ describe('ReactDOMSelect', function() {
280
281 // When removing multiple, defaultValue is applied again, being omitted
282 // means that "monkey" will be selected
279 - React.render(
283 + ReactDOM.render(
284 <select defaultValue="gorilla">{options}</select>,
285 container
286 );
@@ -296,14 +300,14 @@ describe('ReactDOMSelect', function() {
300 </select>;
301 var options = stub.props.children;
302 var container = document.createElement('div');
299 - stub = React.render(stub, container);
300 - var node = React.findDOMNode(stub);
303 + stub = ReactDOM.render(stub, container);
304 + var node = ReactDOM.findDOMNode(stub);
305
306 expect(node.options[0].selected).toBe(false); // monkey
307 expect(node.options[1].selected).toBe(true); // giraffe
308 expect(node.options[2].selected).toBe(false); // gorilla
309
306 - React.render(<select>{options}</select>, container);
310 + ReactDOM.render(<select>{options}</select>, container);
311
312 expect(node.options[0].selected).toBe(false); // monkey
313 expect(node.options[1].selected).toBe(true); // giraffe
@@ -319,10 +323,10 @@ describe('ReactDOMSelect', function() {
323 </select>;
324 var options = stub.props.children;
325 var container = document.createElement('div');
322 - stub = React.render(stub, container);
323 - var node = React.findDOMNode(stub);
326 + stub = ReactDOM.render(stub, container);
327 + var node = ReactDOM.findDOMNode(stub);
328
325 - React.render(
329 + ReactDOM.render(
330 <select value="gorilla" onChange={noop}>{options}</select>,
331 container
332 );
@@ -331,7 +335,7 @@ describe('ReactDOMSelect', function() {
335 expect(node.options[1].selected).toBe(false); // giraffe
336 expect(node.options[2].selected).toBe(true); // gorilla
337
334 - React.render(<select>{options}</select>, container);
338 + ReactDOM.render(<select>{options}</select>, container);
339
340 expect(node.options[0].selected).toBe(false); // monkey
341 expect(node.options[1].selected).toBe(false); // giraffe
@@ -347,7 +351,7 @@ describe('ReactDOMSelect', function() {
351 <option value="gorilla">A gorilla!</option>
352 </select>;
353 stub = ReactTestUtils.renderIntoDocument(stub);
350 - var node = React.findDOMNode(stub);
354 + var node = ReactDOM.findDOMNode(stub);
355
356 expect(node.options[0].selected).toBe(false); // monkey
357 expect(node.options[1].selected).toBe(true); // giraffe
@@ -370,7 +374,7 @@ describe('ReactDOMSelect', function() {
374 <option value="giraffe">A giraffe!</option>
375 <option value="gorilla">A gorilla!</option>
376 </select>;
373 - var markup = React.renderToString(stub);
377 + var markup = ReactDOMServer.renderToString(stub);
378 expect(markup).toContain('<option selected="" value="giraffe"');
379 expect(markup).not.toContain('<option selected="" value="monkey"');
380 expect(markup).not.toContain('<option selected="" value="gorilla"');
@@ -383,7 +387,7 @@ describe('ReactDOMSelect', function() {
387 <option value="giraffe">A giraffe!</option>
388 <option value="gorilla">A gorilla!</option>
389 </select>;
386 - var markup = React.renderToString(stub);
390 + var markup = ReactDOMServer.renderToString(stub);
391 expect(markup).toContain('<option selected="" value="giraffe"');
392 expect(markup).not.toContain('<option selected="" value="monkey"');
393 expect(markup).not.toContain('<option selected="" value="gorilla"');
@@ -396,7 +400,7 @@ describe('ReactDOMSelect', function() {
400 <option value="giraffe">A giraffe!</option>
401 <option value="gorilla">A gorilla!</option>
402 </select>;
399 - var markup = React.renderToString(stub);
403 + var markup = ReactDOMServer.renderToString(stub);
404 expect(markup).toContain('<option selected="" value="giraffe"');
405 expect(markup).toContain('<option selected="" value="gorilla"');
406 expect(markup).not.toContain('<option selected="" value="monkey"');
@@ -405,7 +409,7 @@ describe('ReactDOMSelect', function() {
409 it('should not control defaultValue if readding options', function() {
410 var container = document.createElement('div');
411
408 - var select = React.render(
412 + var select = ReactDOM.render(
413 <select multiple={true} defaultValue={['giraffe']}>
414 <option key="monkey" value="monkey">A monkey!</option>
415 <option key="giraffe" value="giraffe">A giraffe!</option>
@@ -413,13 +417,13 @@ describe('ReactDOMSelect', function() {
417 </select>,
418 container
419 );
416 - var node = React.findDOMNode(select);
420 + var node = ReactDOM.findDOMNode(select);
421
422 expect(node.options[0].selected).toBe(false); // monkey
423 expect(node.options[1].selected).toBe(true); // giraffe
424 expect(node.options[2].selected).toBe(false); // gorilla
425
422 - React.render(
426 + ReactDOM.render(
427 <select multiple={true} defaultValue={['giraffe']}>
428 <option key="monkey" value="monkey">A monkey!</option>
429 <option key="gorilla" value="gorilla">A gorilla!</option>
@@ -430,7 +434,7 @@ describe('ReactDOMSelect', function() {
434 expect(node.options[0].selected).toBe(false); // monkey
435 expect(node.options[1].selected).toBe(false); // gorilla
436
433 - React.render(
437 + ReactDOM.render(
438 <select multiple={true} defaultValue={['giraffe']}>
439 <option key="monkey" value="monkey">A monkey!</option>
440 <option key="giraffe" value="giraffe">A giraffe!</option>
src/renderers/dom/client/wrappers/__tests__/ReactDOMTextarea-test.js
+29 -27
@@ -16,6 +16,7 @@ var mocks = require('mocks');
16
17 describe('ReactDOMTextarea', function() {
18 var React;
19 + var ReactDOM;
20 var ReactLink;
21 var ReactTestUtils;
22
@@ -23,6 +24,7 @@ describe('ReactDOMTextarea', function() {
24
25 beforeEach(function() {
26 React = require('React');
27 + ReactDOM = require('ReactDOM');
28 ReactLink = require('ReactLink');
29 ReactTestUtils = require('ReactTestUtils');
30
@@ -30,8 +32,8 @@ describe('ReactDOMTextarea', function() {
32 if (!container) {
33 container = document.createElement('div');
34 }
33 - var stub = React.render(component, container);
34 - var node = React.findDOMNode(stub);
35 + var stub = ReactDOM.render(component, container);
36 + var node = ReactDOM.findDOMNode(stub);
37 // Fixing jsdom's quirky behavior -- in reality, the parser should strip
38 // off the leading newline but we need to do it by hand here.
39 node.value = node.innerHTML.replace(/^\n/, '');
@@ -42,7 +44,7 @@ describe('ReactDOMTextarea', function() {
44 it('should allow setting `defaultValue`', function() {
45 var container = document.createElement('div');
46 var stub = renderTextarea(<textarea defaultValue="giraffe" />, container);
45 - var node = React.findDOMNode(stub);
47 + var node = ReactDOM.findDOMNode(stub);
48
49 expect(node.value).toBe('giraffe');
50
@@ -54,7 +56,7 @@ describe('ReactDOMTextarea', function() {
56 it('should display `defaultValue` of number 0', function() {
57 var stub = <textarea defaultValue={0} />;
58 stub = renderTextarea(stub);
57 - var node = React.findDOMNode(stub);
59 + var node = ReactDOM.findDOMNode(stub);
60
61 expect(node.value).toBe('0');
62 });
@@ -62,7 +64,7 @@ describe('ReactDOMTextarea', function() {
64 it('should display "false" for `defaultValue` of `false`', function() {
65 var stub = <textarea type="text" defaultValue={false} />;
66 stub = renderTextarea(stub);
65 - var node = React.findDOMNode(stub);
67 + var node = ReactDOM.findDOMNode(stub);
68
69 expect(node.value).toBe('false');
70 });
@@ -76,7 +78,7 @@ describe('ReactDOMTextarea', function() {
78
79 var stub = <textarea type="text" defaultValue={objToString} />;
80 stub = renderTextarea(stub);
79 - var node = React.findDOMNode(stub);
81 + var node = ReactDOM.findDOMNode(stub);
82
83 expect(node.value).toBe('foobar');
84 });
@@ -84,7 +86,7 @@ describe('ReactDOMTextarea', function() {
86 it('should not render value as an attribute', function() {
87 var stub = <textarea value="giraffe" onChange={emptyFunction} />;
88 stub = renderTextarea(stub);
87 - var node = React.findDOMNode(stub);
89 + var node = ReactDOM.findDOMNode(stub);
90
91 expect(node.getAttribute('value')).toBe(null);
92 });
@@ -92,7 +94,7 @@ describe('ReactDOMTextarea', function() {
94 it('should display `value` of number 0', function() {
95 var stub = <textarea value={0} />;
96 stub = renderTextarea(stub);
95 - var node = React.findDOMNode(stub);
97 + var node = ReactDOM.findDOMNode(stub);
98
99 expect(node.value).toBe('0');
100 });
@@ -101,11 +103,11 @@ describe('ReactDOMTextarea', function() {
103 var container = document.createElement('div');
104 var stub = <textarea value="giraffe" onChange={emptyFunction} />;
105 stub = renderTextarea(stub, container);
104 - var node = React.findDOMNode(stub);
106 + var node = ReactDOM.findDOMNode(stub);
107
108 expect(node.value).toBe('giraffe');
109
108 - stub = React.render(
110 + stub = ReactDOM.render(
111 <textarea value="gorilla" onChange={emptyFunction} />,
112 container
113 );
@@ -116,11 +118,11 @@ describe('ReactDOMTextarea', function() {
118 var container = document.createElement('div');
119 var stub = <textarea value="giraffe" onChange={emptyFunction} />;
120 stub = renderTextarea(stub, container);
119 - var node = React.findDOMNode(stub);
121 + var node = ReactDOM.findDOMNode(stub);
122
123 expect(node.value).toBe('giraffe');
124
123 - stub = React.render(
125 + stub = ReactDOM.render(
126 <textarea value={true} onChange={emptyFunction} />,
127 container
128 );
@@ -131,11 +133,11 @@ describe('ReactDOMTextarea', function() {
133 var container = document.createElement('div');
134 var stub = <textarea value="giraffe" onChange={emptyFunction} />;
135 stub = renderTextarea(stub, container);
134 - var node = React.findDOMNode(stub);
136 + var node = ReactDOM.findDOMNode(stub);
137
138 expect(node.value).toBe('giraffe');
139
138 - stub = React.render(
140 + stub = ReactDOM.render(
141 <textarea value={false} onChange={emptyFunction} />,
142 container
143 );
@@ -146,7 +148,7 @@ describe('ReactDOMTextarea', function() {
148 var container = document.createElement('div');
149 var stub = <textarea value="giraffe" onChange={emptyFunction} />;
150 stub = renderTextarea(stub, container);
149 - var node = React.findDOMNode(stub);
151 + var node = ReactDOM.findDOMNode(stub);
152
153 expect(node.value).toBe('giraffe');
154
@@ -155,7 +157,7 @@ describe('ReactDOMTextarea', function() {
157 return 'foo';
158 },
159 };
158 - stub = React.render(
160 + stub = ReactDOM.render(
161 <textarea value={objToString} onChange={emptyFunction} />,
162 container
163 );
@@ -165,7 +167,7 @@ describe('ReactDOMTextarea', function() {
167 it('should properly control a value of number `0`', function() {
168 var stub = <textarea value={0} onChange={emptyFunction} />;
169 stub = renderTextarea(stub);
168 - var node = React.findDOMNode(stub);
170 + var node = ReactDOM.findDOMNode(stub);
171
172 node.value = 'giraffe';
173 ReactTestUtils.Simulate.change(node);
@@ -178,26 +180,26 @@ describe('ReactDOMTextarea', function() {
180 var container = document.createElement('div');
181 var stub = <textarea>giraffe</textarea>;
182 stub = renderTextarea(stub, container);
181 - var node = React.findDOMNode(stub);
183 + var node = ReactDOM.findDOMNode(stub);
184
185 expect(console.error.argsForCall.length).toBe(1);
186 expect(node.value).toBe('giraffe');
187
188 // Changing children should do nothing, it functions like `defaultValue`.
187 - stub = React.render(<textarea>gorilla</textarea>, container);
189 + stub = ReactDOM.render(<textarea>gorilla</textarea>, container);
190 expect(node.value).toEqual('giraffe');
191 });
192
193 it('should allow numbers as children', function() {
194 spyOn(console, 'error');
193 - var node = React.findDOMNode(renderTextarea(<textarea>{17}</textarea>));
195 + var node = ReactDOM.findDOMNode(renderTextarea(<textarea>{17}</textarea>));
196 expect(console.error.argsForCall.length).toBe(1);
197 expect(node.value).toBe('17');
198 });
199
200 it('should allow booleans as children', function() {
201 spyOn(console, 'error');
200 - var node = React.findDOMNode(renderTextarea(<textarea>{false}</textarea>));
202 + var node = ReactDOM.findDOMNode(renderTextarea(<textarea>{false}</textarea>));
203 expect(console.error.argsForCall.length).toBe(1);
204 expect(node.value).toBe('false');
205 });
@@ -209,7 +211,7 @@ describe('ReactDOMTextarea', function() {
211 return 'sharkswithlasers';
212 },
213 };
212 - var node = React.findDOMNode(renderTextarea(<textarea>{obj}</textarea>));
214 + var node = ReactDOM.findDOMNode(renderTextarea(<textarea>{obj}</textarea>));
215 expect(console.error.argsForCall.length).toBe(1);
216 expect(node.value).toBe('sharkswithlasers');
217 });
@@ -227,7 +229,7 @@ describe('ReactDOMTextarea', function() {
229
230 var node;
231 expect(function() {
230 - node = React.findDOMNode(renderTextarea(<textarea><strong /></textarea>));
232 + node = ReactDOM.findDOMNode(renderTextarea(<textarea><strong /></textarea>));
233 }).not.toThrow();
234
235 expect(node.value).toBe('[object Object]');
@@ -241,12 +243,12 @@ describe('ReactDOMTextarea', function() {
243
244 instance = renderTextarea(instance);
245
244 - expect(React.findDOMNode(instance).value).toBe('yolo');
246 + expect(ReactDOM.findDOMNode(instance).value).toBe('yolo');
247 expect(link.value).toBe('yolo');
248 expect(link.requestChange.mock.calls.length).toBe(0);
249
248 - React.findDOMNode(instance).value = 'test';
249 - ReactTestUtils.Simulate.change(React.findDOMNode(instance));
250 + ReactDOM.findDOMNode(instance).value = 'test';
251 + ReactTestUtils.Simulate.change(ReactDOM.findDOMNode(instance));
252
253 expect(link.requestChange.mock.calls.length).toBe(1);
254 expect(link.requestChange.mock.calls[0][0]).toEqual('test');
@@ -255,6 +257,6 @@ describe('ReactDOMTextarea', function() {
257 it('should unmount', function() {
258 var container = document.createElement('div');
259 renderTextarea(<textarea />, container);
258 - React.unmountComponentAtNode(container);
260 + ReactDOM.unmountComponentAtNode(container);
261 });
262 });
src/renderers/dom/server/__tests__/ReactServerRendering-test.js
+11 -9
@@ -15,6 +15,7 @@ var mocks = require('mocks');
15
16 var ExecutionEnvironment;
17 var React;
18 +var ReactDOM;
19 var ReactMarkupChecksum;
20 var ReactReconcileTransaction;
21 var ReactTestUtils;
@@ -26,6 +27,7 @@ describe('ReactServerRendering', function() {
27 beforeEach(function() {
28 require('mock-modules').dumpCache();
29 React = require('React');
30 + ReactDOM = require('ReactDOM');
31 ReactMarkupChecksum = require('ReactMarkupChecksum');
32 ReactTestUtils = require('ReactTestUtils');
33 ReactReconcileTransaction = require('ReactReconcileTransaction');
@@ -185,20 +187,20 @@ describe('ReactServerRendering', function() {
187 });
188
189 var element = document.createElement('div');
188 - React.render(<TestComponent />, element);
190 + ReactDOM.render(<TestComponent />, element);
191
192 var lastMarkup = element.innerHTML;
193
194 // Exercise the update path. Markup should not change,
195 // but some lifecycle methods should be run again.
194 - React.render(<TestComponent name="x" />, element);
196 + ReactDOM.render(<TestComponent name="x" />, element);
197 expect(mountCount).toEqual(1);
198
199 // Unmount and remount. We should get another mount event and
200 // we should get different markup, as the IDs are unique each time.
199 - React.unmountComponentAtNode(element);
201 + ReactDOM.unmountComponentAtNode(element);
202 expect(element.innerHTML).toEqual('');
201 - React.render(<TestComponent name="x" />, element);
203 + ReactDOM.render(<TestComponent name="x" />, element);
204 expect(mountCount).toEqual(2);
205 expect(element.innerHTML).not.toEqual(lastMarkup);
206
@@ -206,7 +208,7 @@ describe('ReactServerRendering', function() {
208 // we used server rendering. We should mount again, but the markup should
209 // be unchanged. We will append a sentinel at the end of innerHTML to be
210 // sure that innerHTML was not changed.
209 - React.unmountComponentAtNode(element);
211 + ReactDOM.unmountComponentAtNode(element);
212 expect(element.innerHTML).toEqual('');
213
214 ExecutionEnvironment.canUseDOM = false;
@@ -216,16 +218,16 @@ describe('ReactServerRendering', function() {
218 ExecutionEnvironment.canUseDOM = true;
219 element.innerHTML = lastMarkup;
220
219 - React.render(<TestComponent name="x" />, element);
221 + ReactDOM.render(<TestComponent name="x" />, element);
222 expect(mountCount).toEqual(3);
223 expect(element.innerHTML).toBe(lastMarkup);
222 - React.unmountComponentAtNode(element);
224 + ReactDOM.unmountComponentAtNode(element);
225 expect(element.innerHTML).toEqual('');
226
227 // Now simulate a situation where the app is not idempotent. React should
228 // warn but do the right thing.
229 element.innerHTML = lastMarkup;
228 - var instance = React.render(<TestComponent name="y" />, element);
230 + var instance = ReactDOM.render(<TestComponent name="y" />, element);
231 expect(mountCount).toEqual(4);
232 expect(console.error.argsForCall.length).toBe(1);
233 expect(element.innerHTML.length > 0).toBe(true);
@@ -233,7 +235,7 @@ describe('ReactServerRendering', function() {
235
236 // Ensure the events system works
237 expect(numClicks).toEqual(0);
236 - ReactTestUtils.Simulate.click(React.findDOMNode(instance.refs.span));
238 + ReactTestUtils.Simulate.click(ReactDOM.findDOMNode(instance.refs.span));
239 expect(numClicks).toEqual(1);
240 });
241
src/renderers/dom/shared/__tests__/CSSPropertyOperations-test.js
+5 -4
@@ -12,6 +12,7 @@
12 'use strict';
13
14 var React = require('React');
15 +var ReactDOM = require('ReactDOM');
16
17 describe('CSSPropertyOperations', function() {
18 var CSSPropertyOperations;
@@ -91,7 +92,7 @@ describe('CSSPropertyOperations', function() {
92 };
93 var div = <div style={styles} />;
94 var root = document.createElement('div');
94 - div = React.render(div, root);
95 + div = ReactDOM.render(div, root);
96 expect(/style=".*"/.test(root.innerHTML)).toBe(true);
97 });
98
@@ -102,7 +103,7 @@ describe('CSSPropertyOperations', function() {
103 };
104 var div = <div style={styles} />;
105 var root = document.createElement('div');
105 - React.render(div, root);
106 + ReactDOM.render(div, root);
107 expect(/style=".*"/.test(root.innerHTML)).toBe(false);
108 });
109
@@ -126,8 +127,8 @@ describe('CSSPropertyOperations', function() {
127 '-webkit-transform': 'translate3d(0, 0, 0)',
128 };
129
129 - React.render(<div />, root);
130 - React.render(<div style={styles} />, root);
130 + ReactDOM.render(<div />, root);
131 + ReactDOM.render(<div style={styles} />, root);
132
133 expect(console.error.argsForCall.length).toBe(2);
134 expect(console.error.argsForCall[0][0]).toContain('msTransform');
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+88 -84
@@ -17,9 +17,14 @@ var mocks = require('mocks');
17 describe('ReactDOMComponent', function() {
18 var React;
19
20 + var ReactDOM;
21 + var ReactDOMServer;
22 +
23 beforeEach(function() {
24 require('mock-modules').dumpCache();
25 React = require('React');
26 + ReactDOM = require('ReactDOM');
27 + ReactDOMServer = require('ReactDOMServer');
28 });
29
30 describe('updateDOM', function() {
@@ -31,31 +36,31 @@ describe('ReactDOMComponent', function() {
36
37 it('should handle className', function() {
38 var container = document.createElement('div');
34 - React.render(<div style={{}} />, container);
39 + ReactDOM.render(<div style={{}} />, container);
40
36 - React.render(<div className={'foo'} />, container);
41 + ReactDOM.render(<div className={'foo'} />, container);
42 expect(container.firstChild.className).toEqual('foo');
38 - React.render(<div className={'bar'} />, container);
43 + ReactDOM.render(<div className={'bar'} />, container);
44 expect(container.firstChild.className).toEqual('bar');
40 - React.render(<div className={null} />, container);
45 + ReactDOM.render(<div className={null} />, container);
46 expect(container.firstChild.className).toEqual('');
47 });
48
49 it('should gracefully handle various style value types', function() {
50 var container = document.createElement('div');
46 - React.render(<div style={{}} />, container);
51 + ReactDOM.render(<div style={{}} />, container);
52 var stubStyle = container.firstChild.style;
53
54 // set initial style
55 var setup = {display: 'block', left: '1', top: 2, fontFamily: 'Arial'};
51 - React.render(<div style={setup} />, container);
56 + ReactDOM.render(<div style={setup} />, container);
57 expect(stubStyle.display).toEqual('block');
58 expect(stubStyle.left).toEqual('1px');
59 expect(stubStyle.fontFamily).toEqual('Arial');
60
61 // reset the style to their default state
62 var reset = {display: '', left: null, top: false, fontFamily: true};
58 - React.render(<div style={reset} />, container);
63 + ReactDOM.render(<div style={reset} />, container);
64 expect(stubStyle.display).toEqual('');
65 expect(stubStyle.left).toEqual('');
66 expect(stubStyle.top).toEqual('');
@@ -69,7 +74,7 @@ describe('ReactDOMComponent', function() {
74
75 var styles = {display: 'none', fontFamily: 'Arial', lineHeight: 1.2};
76 var container = document.createElement('div');
72 - React.render(<div style={styles} />, container);
77 + ReactDOM.render(<div style={styles} />, container);
78
79 var stubStyle = container.firstChild.style;
80 stubStyle.display = styles.display;
@@ -77,26 +82,26 @@ describe('ReactDOMComponent', function() {
82
83 styles.display = 'block';
84
80 - React.render(<div style={styles} />, container);
85 + ReactDOM.render(<div style={styles} />, container);
86 expect(stubStyle.display).toEqual('block');
87 expect(stubStyle.fontFamily).toEqual('Arial');
88 expect(stubStyle.lineHeight).toEqual('1.2');
89
90 styles.fontFamily = 'Helvetica';
91
87 - React.render(<div style={styles} />, container);
92 + ReactDOM.render(<div style={styles} />, container);
93 expect(stubStyle.display).toEqual('block');
94 expect(stubStyle.fontFamily).toEqual('Helvetica');
95 expect(stubStyle.lineHeight).toEqual('1.2');
96
97 styles.lineHeight = 0.5;
98
94 - React.render(<div style={styles} />, container);
99 + ReactDOM.render(<div style={styles} />, container);
100 expect(stubStyle.display).toEqual('block');
101 expect(stubStyle.fontFamily).toEqual('Helvetica');
102 expect(stubStyle.lineHeight).toEqual('0.5');
103
99 - React.render(<div style={undefined} />, container);
104 + ReactDOM.render(<div style={undefined} />, container);
105 expect(stubStyle.display).toBe('');
106 expect(stubStyle.fontFamily).toBe('');
107 expect(stubStyle.lineHeight).toBe('');
@@ -136,73 +141,73 @@ describe('ReactDOMComponent', function() {
141
142 style = {background: 'red'};
143 var div = document.createElement('div');
139 - React.render(<span style={style}></span>, div);
144 + ReactDOM.render(<span style={style}></span>, div);
145 style.background = 'blue';
141 - React.render(<span style={style}></span>, div);
146 + ReactDOM.render(<span style={style}></span>, div);
147 expect(console.error.argsForCall.length).toBe(2);
148 });
149
150 it('should update styles if initially null', function() {
151 var styles = null;
152 var container = document.createElement('div');
148 - React.render(<div style={styles} />, container);
153 + ReactDOM.render(<div style={styles} />, container);
154
155 var stubStyle = container.firstChild.style;
156
157 styles = {display: 'block'};
158
154 - React.render(<div style={styles} />, container);
159 + ReactDOM.render(<div style={styles} />, container);
160 expect(stubStyle.display).toEqual('block');
161 });
162
163 it('should update styles if updated to null multiple times', function() {
164 var styles = null;
165 var container = document.createElement('div');
161 - React.render(<div style={styles} />, container);
166 + ReactDOM.render(<div style={styles} />, container);
167
168 styles = {display: 'block'};
169 var stubStyle = container.firstChild.style;
170
166 - React.render(<div style={styles} />, container);
171 + ReactDOM.render(<div style={styles} />, container);
172 expect(stubStyle.display).toEqual('block');
173
169 - React.render(<div style={null} />, container);
174 + ReactDOM.render(<div style={null} />, container);
175 expect(stubStyle.display).toEqual('');
176
172 - React.render(<div style={styles} />, container);
177 + ReactDOM.render(<div style={styles} />, container);
178 expect(stubStyle.display).toEqual('block');
179
175 - React.render(<div style={null} />, container);
180 + ReactDOM.render(<div style={null} />, container);
181 expect(stubStyle.display).toEqual('');
182 });
183
184 it('should remove attributes', function() {
185 var container = document.createElement('div');
181 - React.render(<img height="17" />, container);
186 + ReactDOM.render(<img height="17" />, container);
187
188 expect(container.firstChild.hasAttribute('height')).toBe(true);
184 - React.render(<img />, container);
189 + ReactDOM.render(<img />, container);
190 expect(container.firstChild.hasAttribute('height')).toBe(false);
191 });
192
193 it('should remove properties', function() {
194 var container = document.createElement('div');
190 - React.render(<div className="monkey" />, container);
195 + ReactDOM.render(<div className="monkey" />, container);
196
197 expect(container.firstChild.className).toEqual('monkey');
193 - React.render(<div />, container);
198 + ReactDOM.render(<div />, container);
199 expect(container.firstChild.className).toEqual('');
200 });
201
202 it('should clear a single style prop when changing `style`', function() {
203 var styles = {display: 'none', color: 'red'};
204 var container = document.createElement('div');
200 - React.render(<div style={styles} />, container);
205 + ReactDOM.render(<div style={styles} />, container);
206
207 var stubStyle = container.firstChild.style;
208
209 styles = {color: 'green'};
205 - React.render(<div style={styles} />, container);
210 + ReactDOM.render(<div style={styles} />, container);
211 expect(stubStyle.display).toEqual('');
212 expect(stubStyle.color).toEqual('green');
213 });
@@ -216,7 +221,7 @@ describe('ReactDOMComponent', function() {
221 {'blah" onclick="beevil" noise="hi': 'selected'},
222 null
223 );
219 - React.render(element, container);
224 + ReactDOM.render(element, container);
225 }
226 expect(console.error.argsForCall.length).toBe(1);
227 expect(console.error.argsForCall[0][0]).toEqual(
@@ -229,14 +234,14 @@ describe('ReactDOMComponent', function() {
234 for (var i = 0; i < 3; i++) {
235 var container = document.createElement('div');
236 var beforeUpdate = React.createElement('x-foo-component', {}, null);
232 - React.render(beforeUpdate, container);
237 + ReactDOM.render(beforeUpdate, container);
238
239 var afterUpdate = React.createElement(
240 'x-foo-component',
241 {'blah" onclick="beevil" noise="hi': 'selected'},
242 null
243 );
239 - React.render(afterUpdate, container);
244 + ReactDOM.render(afterUpdate, container);
245 }
246 expect(console.error.argsForCall.length).toBe(1);
247 expect(console.error.argsForCall[0][0]).toEqual(
@@ -248,10 +253,10 @@ describe('ReactDOMComponent', function() {
253 var container = document.createElement('div');
254
255 var beforeUpdate = React.createElement('x-foo-component', {}, null);
251 - React.render(beforeUpdate, container);
256 + ReactDOM.render(beforeUpdate, container);
257
258 var afterUpdate = <x-foo-component myattr="myval" />;
254 - React.render(afterUpdate, container);
259 + ReactDOM.render(afterUpdate, container);
260
261 expect(container.childNodes[0].getAttribute('myattr')).toBe('myval');
262 });
@@ -259,11 +264,11 @@ describe('ReactDOMComponent', function() {
264 it('should clear all the styles when removing `style`', function() {
265 var styles = {display: 'none', color: 'red'};
266 var container = document.createElement('div');
262 - React.render(<div style={styles} />, container);
267 + ReactDOM.render(<div style={styles} />, container);
268
269 var stubStyle = container.firstChild.style;
270
266 - React.render(<div />, container);
271 + ReactDOM.render(<div />, container);
272 expect(stubStyle.display).toEqual('');
273 expect(stubStyle.color).toEqual('');
274 });
@@ -271,9 +276,9 @@ describe('ReactDOMComponent', function() {
276 it('should update styles when `style` changes from null to object', function() {
277 var container = document.createElement('div');
278 var styles = {color: 'red'};
274 - React.render(<div style={styles} />, container);
275 - React.render(<div />, container);
276 - React.render(<div style={styles} />, container);
279 + ReactDOM.render(<div style={styles} />, container);
280 + ReactDOM.render(<div />, container);
281 + ReactDOM.render(<div style={styles} />, container);
282
283 var stubStyle = container.firstChild.style;
284 expect(stubStyle.color).toEqual('red');
@@ -281,19 +286,19 @@ describe('ReactDOMComponent', function() {
286
287 it('should empty element when removing innerHTML', function() {
288 var container = document.createElement('div');
284 - React.render(<div dangerouslySetInnerHTML={{__html: ':)'}} />, container);
289 + ReactDOM.render(<div dangerouslySetInnerHTML={{__html: ':)'}} />, container);
290
291 expect(container.firstChild.innerHTML).toEqual(':)');
287 - React.render(<div />, container);
292 + ReactDOM.render(<div />, container);
293 expect(container.firstChild.innerHTML).toEqual('');
294 });
295
296 it('should transition from string content to innerHTML', function() {
297 var container = document.createElement('div');
293 - React.render(<div>hello</div>, container);
298 + ReactDOM.render(<div>hello</div>, container);
299
300 expect(container.firstChild.innerHTML).toEqual('hello');
296 - React.render(
301 + ReactDOM.render(
302 <div dangerouslySetInnerHTML={{__html: 'goodbye'}} />,
303 container
304 );
@@ -302,34 +307,34 @@ describe('ReactDOMComponent', function() {
307
308 it('should transition from innerHTML to string content', function() {
309 var container = document.createElement('div');
305 - React.render(
310 + ReactDOM.render(
311 <div dangerouslySetInnerHTML={{__html: 'bonjour'}} />,
312 container
313 );
314
315 expect(container.firstChild.innerHTML).toEqual('bonjour');
311 - React.render(<div>adieu</div>, container);
316 + ReactDOM.render(<div>adieu</div>, container);
317 expect(container.firstChild.innerHTML).toEqual('adieu');
318 });
319
320 it('should transition from innerHTML to children in nested el', function() {
321 var container = document.createElement('div');
317 - React.render(
322 + ReactDOM.render(
323 <div><div dangerouslySetInnerHTML={{__html: 'bonjour'}} /></div>,
324 container
325 );
326
327 expect(container.textContent).toEqual('bonjour');
323 - React.render(<div><div><span>adieu</span></div></div>, container);
328 + ReactDOM.render(<div><div><span>adieu</span></div></div>, container);
329 expect(container.textContent).toEqual('adieu');
330 });
331
332 it('should transition from children to innerHTML in nested el', function() {
333 var container = document.createElement('div');
329 - React.render(<div><div><span>adieu</span></div></div>, container);
334 + ReactDOM.render(<div><div><span>adieu</span></div></div>, container);
335
336 expect(container.textContent).toEqual('adieu');
332 - React.render(
337 + ReactDOM.render(
338 <div><div dangerouslySetInnerHTML={{__html: 'bonjour'}} /></div>,
339 container
340 );
@@ -338,7 +343,7 @@ describe('ReactDOMComponent', function() {
343
344 it('should not incur unnecessary DOM mutations', function() {
345 var container = document.createElement('div');
341 - React.render(<div value="" />, container);
346 + ReactDOM.render(<div value="" />, container);
347
348 var node = container.firstChild;
349 var nodeValue = ''; // node.value always returns undefined
@@ -352,16 +357,16 @@ describe('ReactDOMComponent', function() {
357 }),
358 });
359
355 - React.render(<div value="" />, container);
360 + ReactDOM.render(<div value="" />, container);
361 expect(nodeValueSetter.mock.calls.length).toBe(0);
362
358 - React.render(<div />, container);
363 + ReactDOM.render(<div />, container);
364 expect(nodeValueSetter.mock.calls.length).toBe(1);
365 });
366
367 it('should ignore attribute whitelist for elements with the "is: attribute', function() {
368 var container = document.createElement('div');
364 - React.render(<button is="test" cowabunga="chevynova"/>, container);
369 + ReactDOM.render(<button is="test" cowabunga="chevynova"/>, container);
370 expect(container.firstChild.hasAttribute('cowabunga')).toBe(true);
371 });
372 });
@@ -466,7 +471,7 @@ describe('ReactDOMComponent', function() {
471 beforeEach(function() {
472 mountComponent = function(props) {
473 var container = document.createElement('div');
469 - React.render(<div {...props} />, container);
474 + ReactDOM.render(<div {...props} />, container);
475 };
476 });
477
@@ -476,7 +481,7 @@ describe('ReactDOMComponent', function() {
481 return React.createElement('BR', null);
482 },
483 });
479 - var returnedValue = React.renderToString(<Container/>);
484 + var returnedValue = ReactDOMServer.renderToString(<Container/>);
485 expect(returnedValue).not.toContain('</BR>');
486 });
487
@@ -485,7 +490,7 @@ describe('ReactDOMComponent', function() {
490
491 var container = document.createElement('div');
492
488 - React.render(<input>children</input>, container);
493 + ReactDOM.render(<input>children</input>, container);
494
495 expect(console.error.argsForCall.length).toBe(1);
496 expect(console.error.argsForCall[0][0]).toContain('void element');
@@ -496,7 +501,7 @@ describe('ReactDOMComponent', function() {
501
502 var container = document.createElement('div');
503
499 - React.render(
504 + ReactDOM.render(
505 <input dangerouslySetInnerHTML={{__html: 'content'}} />,
506 container
507 );
@@ -510,11 +515,11 @@ describe('ReactDOMComponent', function() {
515
516 var container = document.createElement('div');
517
513 - var returnedValue = React.renderToString(<menu><menuitem /></menu>);
518 + var returnedValue = ReactDOMServer.renderToString(<menu><menuitem /></menu>);
519
520 expect(returnedValue).toContain('</menuitem>');
521
517 - React.render(<menu><menuitem>children</menuitem></menu>, container);
522 + ReactDOM.render(<menu><menuitem>children</menuitem></menu>, container);
523
524 expect(console.error.argsForCall.length).toBe(1);
525 expect(console.error.argsForCall[0][0]).toContain('void element');
@@ -589,14 +594,14 @@ describe('ReactDOMComponent', function() {
594 SimpleEventPlugin.willDeleteListener = mocks.getMockFunction();
595
596 var container = document.createElement('div');
592 - React.render(
597 + ReactDOM.render(
598 <div onClick={() => true} />,
599 container
600 );
601
602 expect(SimpleEventPlugin.didPutListener.mock.calls.length).toBe(1);
603
599 - React.unmountComponentAtNode(container);
604 + ReactDOM.unmountComponentAtNode(container);
605
606 expect(SimpleEventPlugin.willDeleteListener.mock.calls.length).toBe(1);
607 });
@@ -608,27 +613,27 @@ describe('ReactDOMComponent', function() {
613 SimpleEventPlugin.willDeleteListener = mocks.getMockFunction();
614 var container = document.createElement('div');
615
611 - React.render(<div onClick={null} />, container);
616 + ReactDOM.render(<div onClick={null} />, container);
617 expect(SimpleEventPlugin.didPutListener.mock.calls.length).toBe(0);
618 expect(SimpleEventPlugin.willDeleteListener.mock.calls.length).toBe(0);
619
615 - React.render(<div onClick={() => 'apple'} />, container);
620 + ReactDOM.render(<div onClick={() => 'apple'} />, container);
621 expect(SimpleEventPlugin.didPutListener.mock.calls.length).toBe(1);
622 expect(SimpleEventPlugin.willDeleteListener.mock.calls.length).toBe(0);
623
619 - React.render(<div onClick={() => 'banana'} />, container);
624 + ReactDOM.render(<div onClick={() => 'banana'} />, container);
625 expect(SimpleEventPlugin.didPutListener.mock.calls.length).toBe(2);
626 expect(SimpleEventPlugin.willDeleteListener.mock.calls.length).toBe(0);
627
623 - React.render(<div onClick={null} />, container);
628 + ReactDOM.render(<div onClick={null} />, container);
629 expect(SimpleEventPlugin.didPutListener.mock.calls.length).toBe(2);
630 expect(SimpleEventPlugin.willDeleteListener.mock.calls.length).toBe(1);
631
627 - React.render(<div />, container);
632 + ReactDOM.render(<div />, container);
633 expect(SimpleEventPlugin.didPutListener.mock.calls.length).toBe(2);
634 expect(SimpleEventPlugin.willDeleteListener.mock.calls.length).toBe(1);
635
631 - React.unmountComponentAtNode(container);
636 + ReactDOM.unmountComponentAtNode(container);
637 expect(SimpleEventPlugin.didPutListener.mock.calls.length).toBe(2);
638 expect(SimpleEventPlugin.willDeleteListener.mock.calls.length).toBe(1);
639 });
@@ -641,7 +646,7 @@ describe('ReactDOMComponent', function() {
646 },
647 });
648 var container = document.createElement('div');
644 - React.render(<X />, container);
649 + ReactDOM.render(<X />, container);
650 expect(console.error.argsForCall.length).toBe(1);
651 expect(console.error.argsForCall[0][0]).toBe(
652 'Warning: input is a void element tag and must not have `children` ' +
@@ -660,8 +665,8 @@ describe('ReactDOMComponent', function() {
665 it('should warn against children for void elements', function() {
666 spyOn(console, 'error');
667
663 - React.render(<input />, container);
664 - React.render(<input>children</input>, container);
668 + ReactDOM.render(<input />, container);
669 + ReactDOM.render(<input>children</input>, container);
670
671 expect(console.error.argsForCall.length).toBe(1);
672 expect(console.error.argsForCall[0][0]).toContain('void element');
@@ -670,8 +675,8 @@ describe('ReactDOMComponent', function() {
675 it('should warn against dangerouslySetInnerHTML for void elements', function() {
676 spyOn(console, 'error');
677
673 - React.render(<input />, container);
674 - React.render(
678 + ReactDOM.render(<input />, container);
679 + ReactDOM.render(
680 <input dangerouslySetInnerHTML={{__html: 'content'}} />,
681 container
682 );
@@ -681,10 +686,10 @@ describe('ReactDOMComponent', function() {
686 });
687
688 it('should validate against multiple children props', function() {
684 - React.render(<div></div>, container);
689 + ReactDOM.render(<div></div>, container);
690
691 expect(function() {
687 - React.render(
692 + ReactDOM.render(
693 <div children="" dangerouslySetInnerHTML={{__html: ''}}></div>,
694 container
695 );
@@ -696,7 +701,7 @@ describe('ReactDOMComponent', function() {
701
702 it('should warn about contentEditable and children', function() {
703 spyOn(console, 'error');
699 - React.render(
704 + ReactDOM.render(
705 <div contentEditable={true}><div /></div>,
706 container
707 );
@@ -705,10 +710,10 @@ describe('ReactDOMComponent', function() {
710 });
711
712 it('should validate against invalid styles', function() {
708 - React.render(<div></div>, container);
713 + ReactDOM.render(<div></div>, container);
714
715 expect(function() {
711 - React.render(<div style={1}></div>, container);
716 + ReactDOM.render(<div style={1}></div>, container);
717 }).toThrow(
718 'Invariant Violation: The `style` prop expects a mapping from style ' +
719 'properties to values, not a string. For example, ' +
@@ -718,7 +723,7 @@ describe('ReactDOMComponent', function() {
723
724 it('should properly escape text content and attributes values', function() {
725 expect(
721 - React.renderToStaticMarkup(
726 + ReactDOMServer.renderToStaticMarkup(
727 React.DOM.div({
728 title: '\'"<>&',
729 style: {
@@ -744,16 +749,16 @@ describe('ReactDOMComponent', function() {
749
750 var callback = function() {};
751 var instance = <div onClick={callback} />;
747 - instance = React.render(instance, container);
752 + instance = ReactDOM.render(instance, container);
753
749 - var rootNode = React.findDOMNode(instance);
754 + var rootNode = ReactDOM.findDOMNode(instance);
755 var rootNodeID = ReactMount.getID(rootNode);
756 expect(
757 ReactBrowserEventEmitter.getListener(rootNodeID, 'onClick')
758 ).toBe(callback);
754 - expect(rootNode).toBe(React.findDOMNode(instance));
759 + expect(rootNode).toBe(ReactDOM.findDOMNode(instance));
760
756 - React.unmountComponentAtNode(container);
761 + ReactDOM.unmountComponentAtNode(container);
762
763 expect(
764 ReactBrowserEventEmitter.getListener(rootNodeID, 'onClick')
@@ -825,7 +830,7 @@ describe('ReactDOMComponent', function() {
830 it('warns on invalid nesting at root', () => {
831 spyOn(console, 'error');
832 var p = document.createElement('p');
828 - React.render(<span><p /></span>, p);
833 + ReactDOM.render(<span><p /></span>, p);
834
835 expect(console.error.calls.length).toBe(1);
836 expect(console.error.calls[0].args[0]).toBe(
@@ -954,8 +959,8 @@ describe('ReactDOMComponent', function() {
959 },
960 });
961 var container = document.createElement('div');
957 - React.render(<Animal />, container);
958 - React.unmountComponentAtNode(container);
962 + ReactDOM.render(<Animal />, container);
963 + ReactDOM.unmountComponentAtNode(container);
964 expect(innerDiv.isMounted()).toBe(false);
965
966 expect(console.error.calls.length).toBe(5);
@@ -1011,5 +1016,4 @@ describe('ReactDOMComponent', function() {
1016 expect(typeof node.firstChild.getDOMNode).toBe('undefined');
1017 });
1018 });
1014 -
1019 });
src/renderers/dom/shared/__tests__/ReactDOMTextComponent-test.js
+11 -7
@@ -12,34 +12,38 @@
12 'use strict';
13
14 var React;
15 +var ReactDOM;
16 +var ReactDOMServer;
17
18 describe('ReactDOMTextComponent', function() {
19 beforeEach(function() {
20 React = require('React');
21 + ReactDOM = require('ReactDOM');
22 + ReactDOMServer = require('ReactDOMServer');
23 });
24
25 it('should escape the rootID', function() {
26 var ThisThingShouldBeEscaped = '">>> LULZ <<<"';
27 var ThisThingWasBeEscaped = '&quot;&gt;&gt;&gt; LULZ &lt;&lt;&lt;&quot;';
28 var thing = <div><span key={ThisThingShouldBeEscaped}>LULZ</span></div>;
25 - var html = React.renderToString(thing);
29 + var html = ReactDOMServer.renderToString(thing);
30 expect(html).not.toContain(ThisThingShouldBeEscaped);
31 expect(html).toContain(ThisThingWasBeEscaped);
32 });
33
34 it('updates a mounted text component in place', function() {
35 var el = document.createElement('div');
32 - var inst = React.render(<div>{'foo'}{'bar'}</div>, el);
36 + var inst = ReactDOM.render(<div>{'foo'}{'bar'}</div>, el);
37
34 - var foo = React.findDOMNode(inst).children[0];
35 - var bar = React.findDOMNode(inst).children[1];
38 + var foo = ReactDOM.findDOMNode(inst).children[0];
39 + var bar = ReactDOM.findDOMNode(inst).children[1];
40 expect(foo.tagName).toBe('SPAN');
41 expect(bar.tagName).toBe('SPAN');
42
39 - inst = React.render(<div>{'baz'}{'qux'}</div>, el);
43 + inst = ReactDOM.render(<div>{'baz'}{'qux'}</div>, el);
44 // After the update, the spans should have stayed in place (as opposed to
45 // getting unmounted and remounted)
42 - expect(React.findDOMNode(inst).children[0]).toBe(foo);
43 - expect(React.findDOMNode(inst).children[1]).toBe(bar);
46 + expect(ReactDOM.findDOMNode(inst).children[0]).toBe(foo);
47 + expect(ReactDOM.findDOMNode(inst).children[1]).toBe(bar);
48 });
49 });
src/renderers/shared/reconciler/__tests__/ReactComponent-test.js
+12 -10
@@ -12,6 +12,7 @@
12 'use strict';
13
14 var React;
15 +var ReactDOM;
16 var ReactTestUtils;
17
18 var mocks;
@@ -20,6 +21,7 @@ describe('ReactComponent', function() {
21 beforeEach(function() {
22 mocks = require('mocks');
23 React = require('React');
24 + ReactDOM = require('ReactDOM');
25 ReactTestUtils = require('ReactTestUtils');
26 });
27
@@ -27,14 +29,14 @@ describe('ReactComponent', function() {
29 var container = document.createElement('div');
30 // jQuery objects are basically arrays; people often pass them in by mistake
31 expect(function() {
30 - React.render(<div></div>, [container]);
32 + ReactDOM.render(<div></div>, [container]);
33 }).toThrow(
34 'Invariant Violation: _registerComponent(...): Target container ' +
35 'is not a DOM element.'
36 );
37
38 expect(function() {
37 - React.render(<div></div>, null);
39 + ReactDOM.render(<div></div>, null);
40 }).toThrow(
41 'Invariant Violation: _registerComponent(...): Target container ' +
42 'is not a DOM element.'
@@ -162,7 +164,7 @@ describe('ReactComponent', function() {
164 componentDidMount: function() {
165 // Check .props.title to make sure we got the right elements back
166 expect(this.wrapperRef.getTitle()).toBe('wrapper');
165 - expect(React.findDOMNode(this.innerRef).title).toBe('inner');
167 + expect(ReactDOM.findDOMNode(this.innerRef).title).toBe('inner');
168 mounted = true;
169 },
170 });
@@ -218,11 +220,11 @@ describe('ReactComponent', function() {
220 // mount, update, unmount
221 var el = document.createElement('div');
222 log.push('start mount');
221 - React.render(<Outer />, el);
223 + ReactDOM.render(<Outer />, el);
224 log.push('start update');
223 - React.render(<Outer />, el);
225 + ReactDOM.render(<Outer />, el);
226 log.push('start unmount');
225 - React.unmountComponentAtNode(el);
227 + ReactDOM.unmountComponentAtNode(el);
228
229 expect(log).toEqual([
230 'start mount',
@@ -256,11 +258,11 @@ describe('ReactComponent', function() {
258 it('fires the callback after a component is rendered', function() {
259 var callback = mocks.getMockFunction();
260 var container = document.createElement('div');
259 - React.render(<div />, container, callback);
261 + ReactDOM.render(<div />, container, callback);
262 expect(callback.mock.calls.length).toBe(1);
261 - React.render(<div className="foo" />, container, callback);
263 + ReactDOM.render(<div className="foo" />, container, callback);
264 expect(callback.mock.calls.length).toBe(2);
263 - React.render(<span />, container, callback);
265 + ReactDOM.render(<span />, container, callback);
266 expect(callback.mock.calls.length).toBe(3);
267 });
268
@@ -273,7 +275,7 @@ describe('ReactComponent', function() {
275 },
276 });
277 var container = document.createElement('div');
276 - var instance = React.render(<Potato />, container);
278 + var instance = ReactDOM.render(<Potato />, container);
279
280 instance.getDOMNode();
281
src/renderers/shared/reconciler/__tests__/ReactComponentLifeCycle-test.js
+16 -14
@@ -14,6 +14,7 @@
14 var keyMirror = require('keyMirror');
15
16 var React;
17 +var ReactDOM;
18 var ReactInstanceMap;
19 var ReactTestUtils;
20
@@ -99,6 +100,7 @@ describe('ReactComponentLifeCycle', function() {
100 beforeEach(function() {
101 require('mock-modules').dumpCache();
102 React = require('React');
103 + ReactDOM = require('ReactDOM');
104 ReactTestUtils = require('ReactTestUtils');
105 ReactInstanceMap = require('ReactInstanceMap');
106 });
@@ -116,9 +118,9 @@ describe('ReactComponentLifeCycle', function() {
118 },
119 });
120 var element = <StatefulComponent />;
119 - var firstInstance = React.render(element, container);
120 - React.unmountComponentAtNode(container);
121 - var secondInstance = React.render(element, container);
121 + var firstInstance = ReactDOM.render(element, container);
122 + ReactDOM.unmountComponentAtNode(container);
123 + var secondInstance = ReactDOM.render(element, container);
124 expect(firstInstance).not.toBe(secondInstance);
125 });
126
@@ -291,11 +293,11 @@ describe('ReactComponentLifeCycle', function() {
293 });
294
295 var container = document.createElement('div');
294 - var instance = React.render(<Component />, container);
296 + var instance = ReactDOM.render(<Component />, container);
297
298 expect(instance.isMounted()).toBe(true);
299
298 - React.unmountComponentAtNode(container);
300 + ReactDOM.unmountComponentAtNode(container);
301
302 expect(instance.isMounted()).toBe(false);
303 });
@@ -311,7 +313,7 @@ describe('ReactComponentLifeCycle', function() {
313 },
314 render: function() {
315 if (this.state.isMounted) {
314 - expect(React.findDOMNode(this).tagName).toBe('DIV');
316 + expect(ReactDOM.findDOMNode(this).tagName).toBe('DIV');
317 }
318 return <div/>;
319 },
@@ -384,7 +386,7 @@ describe('ReactComponentLifeCycle', function() {
386 // yet initialized, or rendered.
387 //
388 var container = document.createElement('div');
387 - var instance = React.render(<LifeCycleComponent />, container);
389 + var instance = ReactDOM.render(<LifeCycleComponent />, container);
390
391 // getInitialState
392 expect(instance._testJournal.returnedFromGetInitialState).toEqual(
@@ -428,7 +430,7 @@ describe('ReactComponentLifeCycle', function() {
430
431 expect(getLifeCycleState(instance)).toBe(ComponentLifeCycle.MOUNTED);
432
431 - React.unmountComponentAtNode(container);
433 + ReactDOM.unmountComponentAtNode(container);
434
435 expect(instance._testJournal.stateAtStartOfWillUnmount)
436 .toEqual(WILL_UNMOUNT_STATE);
@@ -499,7 +501,7 @@ describe('ReactComponentLifeCycle', function() {
501 updateTooltip: function() {
502 // Even though this.props.tooltip has an owner, updating it shouldn't
503 // throw here because it's mounted as a root component
502 - React.render(this.props.tooltip, this.container);
504 + ReactDOM.render(this.props.tooltip, this.container);
505 },
506 });
507 var Component = React.createClass({
@@ -515,14 +517,14 @@ describe('ReactComponentLifeCycle', function() {
517 });
518
519 var container = document.createElement('div');
518 - React.render(
520 + ReactDOM.render(
521 <Component text="uno" tooltipText="one" />,
522 container
523 );
524
525 // Since `instance` is a root component, we can set its props. This also
526 // makes Tooltip rerender the tooltip component, which shouldn't throw.
525 - React.render(
527 + ReactDOM.render(
528 <Component text="dos" tooltipText="two" />,
529 container
530 );
@@ -591,7 +593,7 @@ describe('ReactComponentLifeCycle', function() {
593
594 var container = document.createElement('div');
595 log = [];
594 - React.render(<Outer x={17} />, container);
596 + ReactDOM.render(<Outer x={17} />, container);
597 expect(log).toEqual([
598 'outer componentWillMount',
599 'inner componentWillMount',
@@ -600,7 +602,7 @@ describe('ReactComponentLifeCycle', function() {
602 ]);
603
604 log = [];
603 - React.render(<Outer x={42} />, container);
605 + ReactDOM.render(<Outer x={42} />, container);
606 expect(log).toEqual([
607 'outer componentWillReceiveProps',
608 'outer shouldComponentUpdate',
@@ -613,7 +615,7 @@ describe('ReactComponentLifeCycle', function() {
615 ]);
616
617 log = [];
616 - React.unmountComponentAtNode(container);
618 + ReactDOM.unmountComponentAtNode(container);
619 expect(log).toEqual([
620 'outer componentWillUnmount',
621 'inner componentWillUnmount',
src/renderers/shared/reconciler/__tests__/ReactCompositeComponent-test.js
+44 -42
@@ -14,6 +14,7 @@
14 var ChildUpdates;
15 var MorphingComponent;
16 var React;
17 +var ReactDOM;
18 var ReactCurrentOwner;
19 var ReactMount;
20 var ReactPropTypes;
@@ -29,6 +30,7 @@ describe('ReactCompositeComponent', function() {
30 require('mock-modules').dumpCache();
31 reactComponentExpect = require('reactComponentExpect');
32 React = require('React');
33 + ReactDOM = require('ReactDOM');
34 ReactCurrentOwner = require('ReactCurrentOwner');
35 ReactPropTypes = require('ReactPropTypes');
36 ReactTestUtils = require('ReactTestUtils');
@@ -107,7 +109,7 @@ describe('ReactCompositeComponent', function() {
109 var container = document.createElement('div');
110 container.innerHTML = markup;
111
110 - React.render(<Parent />, container);
112 + ReactDOM.render(<Parent />, container);
113 expect(console.error).not.toHaveBeenCalled();
114 });
115
@@ -129,11 +131,11 @@ describe('ReactCompositeComponent', function() {
131 var instance = <MorphingComponent />;
132 instance = ReactTestUtils.renderIntoDocument(instance);
133
132 - expect(React.findDOMNode(instance.refs.x).tagName).toBe('A');
134 + expect(ReactDOM.findDOMNode(instance.refs.x).tagName).toBe('A');
135 instance._toggleActivatedState();
134 - expect(React.findDOMNode(instance.refs.x).tagName).toBe('B');
136 + expect(ReactDOM.findDOMNode(instance.refs.x).tagName).toBe('B');
137 instance._toggleActivatedState();
136 - expect(React.findDOMNode(instance.refs.x).tagName).toBe('A');
138 + expect(ReactDOM.findDOMNode(instance.refs.x).tagName).toBe('A');
139 });
140
141 it('should not cache old DOM nodes when switching constructors', function() {
@@ -144,7 +146,7 @@ describe('ReactCompositeComponent', function() {
146 // rerender
147 instance.setProps({renderAnchor: true, anchorClassOn: false});
148 var anchor = instance.getAnchor();
147 - var actualDOMAnchorNode = React.findDOMNode(anchor);
149 + var actualDOMAnchorNode = ReactDOM.findDOMNode(anchor);
150 expect(actualDOMAnchorNode.className).toBe('');
151 expect(actualDOMAnchorNode).toBe(anchor.getDOMNode());
152 });
@@ -262,12 +264,12 @@ describe('ReactCompositeComponent', function() {
264 var instance = <Component />;
265 expect(instance.forceUpdate).not.toBeDefined();
266
265 - instance = React.render(instance, container);
267 + instance = ReactDOM.render(instance, container);
268 instance.forceUpdate();
269
270 expect(console.error.calls.length).toBe(0);
271
270 - React.unmountComponentAtNode(container);
272 + ReactDOM.unmountComponentAtNode(container);
273
274 instance.forceUpdate();
275 expect(console.error.calls.length).toBe(1);
@@ -298,7 +300,7 @@ describe('ReactCompositeComponent', function() {
300 var instance = <Component />;
301 expect(instance.setState).not.toBeDefined();
302
301 - instance = React.render(instance, container);
303 + instance = ReactDOM.render(instance, container);
304
305 expect(renders).toBe(1);
306
@@ -308,7 +310,7 @@ describe('ReactCompositeComponent', function() {
310
311 expect(renders).toBe(2);
312
311 - React.unmountComponentAtNode(container);
313 + ReactDOM.unmountComponentAtNode(container);
314 instance.setState({value: 2});
315
316 expect(renders).toBe(2);
@@ -344,12 +346,12 @@ describe('ReactCompositeComponent', function() {
346 },
347 });
348
347 - var instance = React.render(<Component />, container);
349 + var instance = ReactDOM.render(<Component />, container);
350
351 instance.setState({value: 1});
352 expect(console.error.calls.length).toBe(0);
353
352 - React.unmountComponentAtNode(container);
354 + ReactDOM.unmountComponentAtNode(container);
355 expect(console.error.calls.length).toBe(0);
356 expect(cbCalled).toBe(false);
357 });
@@ -377,7 +379,7 @@ describe('ReactCompositeComponent', function() {
379
380 expect(console.error.calls.length).toBe(0);
381
380 - var instance = React.render(<Component />, container);
382 + var instance = ReactDOM.render(<Component />, container);
383
384 expect(console.error.calls.length).toBe(1);
385 expect(console.error.argsForCall[0][0]).toBe(
@@ -394,7 +396,7 @@ describe('ReactCompositeComponent', function() {
396 expect(instance.state.value).toBe(1);
397
398 // Forcing a rerender anywhere will cause the update to happen.
397 - var instance2 = React.render(<Component prop={123} />, container);
399 + var instance2 = ReactDOM.render(<Component prop={123} />, container);
400 expect(instance).toBe(instance2);
401 expect(renderedState).toBe(1);
402 expect(instance2.state.value).toBe(1);
@@ -413,13 +415,13 @@ describe('ReactCompositeComponent', function() {
415 var instance = <Component />;
416 expect(instance.setProps).not.toBeDefined();
417
416 - instance = React.render(instance, container);
418 + instance = ReactDOM.render(instance, container);
419 expect(function() {
420 instance.setProps({value: 1});
421 }).not.toThrow();
422 expect(console.error.calls.length).toBe(1); // setProps deprecated
423
422 - React.unmountComponentAtNode(container);
424 + ReactDOM.unmountComponentAtNode(container);
425 expect(function() {
426 instance.setProps({value: 2});
427 }).not.toThrow();
@@ -452,7 +454,7 @@ describe('ReactCompositeComponent', function() {
454 innerInstance = this.refs.inner;
455 },
456 });
455 - React.render(<Component />, container);
457 + ReactDOM.render(<Component />, container);
458
459 expect(innerInstance).not.toBe(undefined);
460 expect(function() {
@@ -513,8 +515,8 @@ describe('ReactCompositeComponent', function() {
515 },
516 });
517
516 - React.render(<Component />, container);
517 - React.unmountComponentAtNode(container);
518 + ReactDOM.render(<Component />, container);
519 + ReactDOM.unmountComponentAtNode(container);
520 expect(innerUnmounted).toBe(true);
521
522 // The text and both <div /> elements and their wrappers each call
@@ -603,7 +605,7 @@ describe('ReactCompositeComponent', function() {
605 });
606
607 var component = ReactTestUtils.renderIntoDocument(<Parent />);
606 - expect(React.findDOMNode(component).innerHTML).toBe('bar');
608 + expect(ReactDOM.findDOMNode(component).innerHTML).toBe('bar');
609 });
610
611 it('should pass context when re-rendered for static child', function() {
@@ -848,13 +850,13 @@ describe('ReactCompositeComponent', function() {
850 });
851
852 var div = document.createElement('div');
851 - React.render(<Parent cntxt="noise" />, div);
853 + ReactDOM.render(<Parent cntxt="noise" />, div);
854 expect(div.children[0].innerHTML).toBe('noise');
855 div.children[0].innerHTML = 'aliens';
856 div.children[0].id = 'aliens';
857 expect(div.children[0].innerHTML).toBe('aliens');
858 expect(div.children[0].id).toBe('aliens');
857 - React.render(<Parent cntxt="bar" />, div);
859 + ReactDOM.render(<Parent cntxt="bar" />, div);
860 expect(div.children[0].innerHTML).toBe('bar');
861 expect(div.children[0].id).toBe('aliens');
862 });
@@ -899,10 +901,10 @@ describe('ReactCompositeComponent', function() {
901 });
902
903 var container = document.createElement('div');
902 - var instance = React.render(<Component update={0} />, container);
904 + var instance = ReactDOM.render(<Component update={0} />, container);
905 expect(renders).toBe(1);
906 expect(instance.state.updated).toBe(false);
905 - React.render(<Component update={1} />, container);
907 + ReactDOM.render(<Component update={1} />, container);
908 expect(renders).toBe(2);
909 expect(instance.state.updated).toBe(true);
910 });
@@ -937,24 +939,24 @@ describe('ReactCompositeComponent', function() {
939 });
940
941 var container = document.createElement('div');
940 - var comp = React.render(<Component flipped={false} />, container);
941 - expect(React.findDOMNode(comp.refs.static0).textContent).toBe('A');
942 - expect(React.findDOMNode(comp.refs.static1).textContent).toBe('B');
942 + var comp = ReactDOM.render(<Component flipped={false} />, container);
943 + expect(ReactDOM.findDOMNode(comp.refs.static0).textContent).toBe('A');
944 + expect(ReactDOM.findDOMNode(comp.refs.static1).textContent).toBe('B');
945
944 - expect(React.findDOMNode(comp.refs.static0))
946 + expect(ReactDOM.findDOMNode(comp.refs.static0))
947 .toBe(comp.refs.static0.getDOMNode());
946 - expect(React.findDOMNode(comp.refs.static1))
948 + expect(ReactDOM.findDOMNode(comp.refs.static1))
949 .toBe(comp.refs.static1.getDOMNode());
950
951 // When flipping the order, the refs should update even though the actual
952 // contents do not
951 - React.render(<Component flipped={true} />, container);
952 - expect(React.findDOMNode(comp.refs.static0).textContent).toBe('B');
953 - expect(React.findDOMNode(comp.refs.static1).textContent).toBe('A');
953 + ReactDOM.render(<Component flipped={true} />, container);
954 + expect(ReactDOM.findDOMNode(comp.refs.static0).textContent).toBe('B');
955 + expect(ReactDOM.findDOMNode(comp.refs.static1).textContent).toBe('A');
956
955 - expect(React.findDOMNode(comp.refs.static0))
957 + expect(ReactDOM.findDOMNode(comp.refs.static0))
958 .toBe(comp.refs.static0.getDOMNode());
957 - expect(React.findDOMNode(comp.refs.static1))
959 + expect(ReactDOM.findDOMNode(comp.refs.static1))
960 .toBe(comp.refs.static1.getDOMNode());
961 });
962
@@ -963,11 +965,11 @@ describe('ReactCompositeComponent', function() {
965 var b = null;
966 var Component = React.createClass({
967 componentDidMount: function() {
966 - a = React.findDOMNode(this);
968 + a = ReactDOM.findDOMNode(this);
969 expect(a).toBe(this.getDOMNode());
970 },
971 componentWillUnmount: function() {
970 - b = React.findDOMNode(this);
972 + b = ReactDOM.findDOMNode(this);
973 expect(b).toBe(this.getDOMNode());
974 },
975 render: function() {
@@ -976,8 +978,8 @@ describe('ReactCompositeComponent', function() {
978 });
979 var container = document.createElement('div');
980 expect(a).toBe(container.firstChild);
979 - React.render(<Component />, container);
980 - React.unmountComponentAtNode(container);
981 + ReactDOM.render(<Component />, container);
982 + ReactDOM.unmountComponentAtNode(container);
983 expect(a).toBe(b);
984 });
985
@@ -1022,7 +1024,7 @@ describe('ReactCompositeComponent', function() {
1024 });
1025
1026 var div = document.createElement('div');
1025 - React.render(<Parent><Component /></Parent>, div);
1027 + ReactDOM.render(<Parent><Component /></Parent>, div);
1028
1029 expect(console.error.argsForCall.length).toBe(0);
1030 });
@@ -1098,11 +1100,11 @@ describe('ReactCompositeComponent', function() {
1100
1101 var Component = React.createClass({
1102 componentWillMount: function() {
1101 - React.render(<div />, layer);
1103 + ReactDOM.render(<div />, layer);
1104 },
1105
1106 componentWillUnmount: function() {
1105 - React.unmountComponentAtNode(layer);
1107 + ReactDOM.unmountComponentAtNode(layer);
1108 },
1109
1110 render: function() {
@@ -1116,11 +1118,11 @@ describe('ReactCompositeComponent', function() {
1118 },
1119 });
1120
1119 - React.render(<Outer><Component /></Outer>, container);
1121 + ReactDOM.render(<Outer><Component /></Outer>, container);
1122
1123 expect(console.error.calls.length).toBe(0);
1124
1123 - React.render(<Outer />, container);
1125 + ReactDOM.render(<Outer />, container);
1126
1127 expect(console.error.calls.length).toBe(0);
1128 });
src/renderers/shared/reconciler/__tests__/ReactCompositeComponentNestedState-test.js
+3 -1
@@ -14,12 +14,14 @@
14 var mocks = require('mocks');
15
16 var React;
17 +var ReactDOM;
18 var ReactTestUtils;
19
20 describe('ReactCompositeComponentNestedState-state', function() {
21
22 beforeEach(function() {
23 React = require('React');
24 + ReactDOM = require('ReactDOM');
25 ReactTestUtils = require('ReactTestUtils');
26 });
27
@@ -92,7 +94,7 @@ describe('ReactCompositeComponentNestedState-state', function() {
94
95 var logger = mocks.getMockFunction();
96
95 - void React.render(
97 + void ReactDOM.render(
98 <ParentComponent logger={logger} />,
99 container
100 );
src/renderers/shared/reconciler/__tests__/ReactCompositeComponentState-test.js
+8 -6
@@ -14,6 +14,7 @@
14 var mocks = require('mocks');
15
16 var React;
17 +var ReactDOM;
18
19 var TestComponent;
20
@@ -22,6 +23,8 @@ describe('ReactCompositeComponent-state', function() {
23 beforeEach(function() {
24 React = require('React');
25
26 + ReactDOM = require('ReactDOM');
27 +
28 TestComponent = React.createClass({
29 peekAtState: function(from, state) {
30 state = state || this.state;
@@ -123,7 +126,6 @@ describe('ReactCompositeComponent-state', function() {
126 this.peekAtState('componentWillUnmount');
127 },
128 });
126 -
129 });
130
131 it('should support setting state', function() {
@@ -131,14 +133,14 @@ describe('ReactCompositeComponent-state', function() {
133 document.body.appendChild(container);
134
135 var stateListener = mocks.getMockFunction();
134 - var instance = React.render(
136 + var instance = ReactDOM.render(
137 <TestComponent stateListener={stateListener} />,
138 container,
139 function peekAtInitialCallback() {
140 this.peekAtState('initial-callback');
141 }
142 );
141 - React.render(
143 + ReactDOM.render(
144 <TestComponent stateListener={stateListener} nextColor="green" />,
145 container,
146 instance.peekAtCallback('setProps')
@@ -146,7 +148,7 @@ describe('ReactCompositeComponent-state', function() {
148 instance.setFavoriteColor('blue');
149 instance.forceUpdate(instance.peekAtCallback('forceUpdate'));
150
149 - React.unmountComponentAtNode(container);
151 + ReactDOM.unmountComponentAtNode(container);
152
153 expect(stateListener.mock.calls.join('\n')).toEqual([
154 // there is no state when getInitialState() is called
@@ -238,9 +240,9 @@ describe('ReactCompositeComponent-state', function() {
240 });
241
242 var container = document.createElement('div');
241 - outer = React.render(<Outer />, container);
243 + outer = ReactDOM.render(<Outer />, container);
244 expect(() => {
243 - React.unmountComponentAtNode(container);
245 + ReactDOM.unmountComponentAtNode(container);
246 }).not.toThrow();
247 });
248 });
src/renderers/shared/reconciler/__tests__/ReactEmptyComponent-test.js
+13 -11
@@ -12,6 +12,7 @@
12 'use strict';
13
14 var React;
15 +var ReactDOM;
16 var ReactEmptyComponent;
17 var ReactTestUtils;
18 var TogglingComponent;
@@ -23,6 +24,7 @@ describe('ReactEmptyComponent', function() {
24 require('mock-modules').dumpCache();
25
26 React = require('React');
27 + ReactDOM = require('ReactDOM');
28 ReactEmptyComponent = require('ReactEmptyComponent');
29 ReactTestUtils = require('ReactTestUtils');
30
@@ -33,11 +35,11 @@ describe('ReactEmptyComponent', function() {
35 return {component: this.props.firstComponent};
36 },
37 componentDidMount: function() {
36 - console.log(React.findDOMNode(this));
38 + console.log(ReactDOM.findDOMNode(this));
39 this.setState({component: this.props.secondComponent});
40 },
41 componentDidUpdate: function() {
40 - console.log(React.findDOMNode(this));
42 + console.log(ReactDOM.findDOMNode(this));
43 },
44 render: function() {
45 var Component = this.state.component;
@@ -188,13 +190,13 @@ describe('ReactEmptyComponent', function() {
190 componentDidMount: function() {
191 // Make sure the DOM node resolves properly even if we're replacing a
192 // `null` component
191 - expect(React.findDOMNode(this)).not.toBe(null);
193 + expect(ReactDOM.findDOMNode(this)).not.toBe(null);
194 assertions++;
195 },
196 componentWillUnmount: function() {
197 // Even though we're getting replaced by `null`, we haven't been
198 // replaced yet!
197 - expect(React.findDOMNode(this)).not.toBe(null);
199 + expect(ReactDOM.findDOMNode(this)).not.toBe(null);
200 assertions++;
201 },
202 });
@@ -208,16 +210,16 @@ describe('ReactEmptyComponent', function() {
210 var component;
211
212 // Render the <Inner /> component...
211 - component = React.render(<Wrapper showInner={true} />, el);
212 - expect(React.findDOMNode(component)).not.toBe(null);
213 + component = ReactDOM.render(<Wrapper showInner={true} />, el);
214 + expect(ReactDOM.findDOMNode(component)).not.toBe(null);
215
216 // Switch to null...
215 - component = React.render(<Wrapper showInner={false} />, el);
216 - expect(React.findDOMNode(component)).toBe(null);
217 + component = ReactDOM.render(<Wrapper showInner={false} />, el);
218 + expect(ReactDOM.findDOMNode(component)).toBe(null);
219
220 // ...then switch back.
219 - component = React.render(<Wrapper showInner={true} />, el);
220 - expect(React.findDOMNode(component)).not.toBe(null);
221 + component = ReactDOM.render(<Wrapper showInner={true} />, el);
222 + expect(ReactDOM.findDOMNode(component)).not.toBe(null);
223
224 expect(assertions).toBe(3);
225 });
@@ -226,7 +228,7 @@ describe('ReactEmptyComponent', function() {
228 // TODO: This should actually work since `null` is a valid ReactNode
229 var div = document.createElement('div');
230 expect(function() {
229 - React.render(null, div);
231 + ReactDOM.render(null, div);
232 }).toThrow(
233 'Invariant Violation: React.render(): Invalid component element.'
234 );
src/renderers/shared/reconciler/__tests__/ReactIdentity-test.js
+16 -14
@@ -12,6 +12,7 @@
12 'use strict';
13
14 var React;
15 +var ReactDOM;
16 var ReactFragment;
17 var ReactTestUtils;
18 var ReactMount;
@@ -21,6 +22,7 @@ describe('ReactIdentity', function() {
22 beforeEach(function() {
23 require('mock-modules').dumpCache();
24 React = require('React');
25 + ReactDOM = require('ReactDOM');
26 ReactFragment = require('ReactFragment');
27 ReactTestUtils = require('ReactTestUtils');
28 ReactMount = require('ReactMount');
@@ -48,8 +50,8 @@ describe('ReactIdentity', function() {
50 })}
51 </div>;
52
51 - instance = React.render(instance, document.createElement('div'));
52 - var node = React.findDOMNode(instance);
53 + instance = ReactDOM.render(instance, document.createElement('div'));
54 + var node = ReactDOM.findDOMNode(instance);
55 expect(node.childNodes.length).toBe(2);
56 checkID(node.childNodes[0], '.0.$first:0');
57 checkID(node.childNodes[1], '.0.$second:0');
@@ -64,8 +66,8 @@ describe('ReactIdentity', function() {
66 <div key={123} />
67 </div>;
68
67 - instance = React.render(instance, document.createElement('div'));
68 - var node = React.findDOMNode(instance);
69 + instance = ReactDOM.render(instance, document.createElement('div'));
70 + var node = ReactDOM.findDOMNode(instance);
71 expect(node.childNodes.length).toBe(4);
72 checkID(node.childNodes[0], '.0.$apple');
73 checkID(node.childNodes[1], '.0.$banana');
@@ -88,8 +90,8 @@ describe('ReactIdentity', function() {
90 <Wrapper><span key="chipmunk" /></Wrapper>
91 </div>;
92
91 - instance = React.render(instance, document.createElement('div'));
92 - var node = React.findDOMNode(instance);
93 + instance = ReactDOM.render(instance, document.createElement('div'));
94 + var node = ReactDOM.findDOMNode(instance);
95 expect(node.childNodes.length).toBe(3);
96
97 checkID(node.childNodes[0], '.0.$wrap1');
@@ -115,17 +117,17 @@ describe('ReactIdentity', function() {
117
118 });
119
118 - var instance = React.render(<Wrapper />, container);
120 + var instance = ReactDOM.render(<Wrapper />, container);
121 var span1 = instance.refs.span1;
122 var span2 = instance.refs.span2;
123
122 - expect(React.findDOMNode(span1)).not.toBe(null);
123 - expect(React.findDOMNode(span2)).not.toBe(null);
124 + expect(ReactDOM.findDOMNode(span1)).not.toBe(null);
125 + expect(ReactDOM.findDOMNode(span2)).not.toBe(null);
126
127 key = key.replace(/=/g, '=0');
128
127 - checkID(React.findDOMNode(span1), '.0.$' + key);
128 - checkID(React.findDOMNode(span2), '.0.1:$' + key + ':0');
129 + checkID(ReactDOM.findDOMNode(span1), '.0.$' + key);
130 + checkID(ReactDOM.findDOMNode(span2), '.0.1:$' + key + ':0');
131 }
132
133 it('should allow any character as a key, in a detached parent', function() {
@@ -294,13 +296,13 @@ describe('ReactIdentity', function() {
296
297 var wrapped = <TestContainer first={instance0} second={instance1} />;
298
297 - wrapped = React.render(wrapped, document.createElement('div'));
299 + wrapped = ReactDOM.render(wrapped, document.createElement('div'));
300
299 - var beforeID = ReactMount.getID(React.findDOMNode(wrapped).firstChild);
301 + var beforeID = ReactMount.getID(ReactDOM.findDOMNode(wrapped).firstChild);
302
303 wrapped.swap();
304
303 - var afterID = ReactMount.getID(React.findDOMNode(wrapped).firstChild);
305 + var afterID = ReactMount.getID(ReactDOM.findDOMNode(wrapped).firstChild);
306
307 expect(beforeID).not.toEqual(afterID);
308
src/renderers/shared/reconciler/__tests__/ReactMultiChild-test.js
+14 -11
@@ -16,9 +16,12 @@ var mocks = require('mocks');
16 describe('ReactMultiChild', function() {
17 var React;
18
19 + var ReactDOM;
20 +
21 beforeEach(function() {
22 require('mock-modules').dumpCache();
23 React = require('React');
24 + ReactDOM = require('ReactDOM');
25 });
26
27 describe('reconciliation', function() {
@@ -42,13 +45,13 @@ describe('ReactMultiChild', function() {
45 expect(mockUpdate.mock.calls.length).toBe(0);
46 expect(mockUnmount.mock.calls.length).toBe(0);
47
45 - React.render(<div><MockComponent /></div>, container);
48 + ReactDOM.render(<div><MockComponent /></div>, container);
49
50 expect(mockMount.mock.calls.length).toBe(1);
51 expect(mockUpdate.mock.calls.length).toBe(0);
52 expect(mockUnmount.mock.calls.length).toBe(0);
53
51 - React.render(<div><MockComponent /></div>, container);
54 + ReactDOM.render(<div><MockComponent /></div>, container);
55
56 expect(mockMount.mock.calls.length).toBe(1);
57 expect(mockUpdate.mock.calls.length).toBe(1);
@@ -72,12 +75,12 @@ describe('ReactMultiChild', function() {
75 expect(mockMount.mock.calls.length).toBe(0);
76 expect(mockUnmount.mock.calls.length).toBe(0);
77
75 - React.render(<div><MockComponent /></div>, container);
78 + ReactDOM.render(<div><MockComponent /></div>, container);
79
80 expect(mockMount.mock.calls.length).toBe(1);
81 expect(mockUnmount.mock.calls.length).toBe(0);
82
80 - React.render(<div><span /></div>, container);
83 + ReactDOM.render(<div><span /></div>, container);
84
85 expect(mockMount.mock.calls.length).toBe(1);
86 expect(mockUnmount.mock.calls.length).toBe(1);
@@ -106,12 +109,12 @@ describe('ReactMultiChild', function() {
109 expect(mockMount.mock.calls.length).toBe(0);
110 expect(mockUnmount.mock.calls.length).toBe(0);
111
109 - React.render(<WrapperComponent />, container);
112 + ReactDOM.render(<WrapperComponent />, container);
113
114 expect(mockMount.mock.calls.length).toBe(1);
115 expect(mockUnmount.mock.calls.length).toBe(0);
116
114 - React.render(
117 + ReactDOM.render(
118 <WrapperComponent><MockComponent /></WrapperComponent>,
119 container
120 );
@@ -137,12 +140,12 @@ describe('ReactMultiChild', function() {
140 expect(mockMount.mock.calls.length).toBe(0);
141 expect(mockUnmount.mock.calls.length).toBe(0);
142
140 - React.render(<div><MockComponent key="A" /></div>, container);
143 + ReactDOM.render(<div><MockComponent key="A" /></div>, container);
144
145 expect(mockMount.mock.calls.length).toBe(1);
146 expect(mockUnmount.mock.calls.length).toBe(0);
147
145 - React.render(<div><MockComponent key="B" /></div>, container);
148 + ReactDOM.render(<div><MockComponent key="B" /></div>, container);
149
150 expect(mockMount.mock.calls.length).toBe(2);
151 expect(mockUnmount.mock.calls.length).toBe(1);
@@ -172,7 +175,7 @@ describe('ReactMultiChild', function() {
175 it('should only set `innerHTML` once on update', function() {
176 var container = document.createElement('div');
177
175 - React.render(
178 + ReactDOM.render(
179 <div>
180 <p><span /></p>
181 <p><span /></p>
@@ -181,7 +184,7 @@ describe('ReactMultiChild', function() {
184 container
185 );
186 // Warm the cache used by `getMarkupWrap`.
184 - React.render(
187 + ReactDOM.render(
188 <div>
189 <p><span /><span /></p>
190 <p><span /><span /></p>
@@ -192,7 +195,7 @@ describe('ReactMultiChild', function() {
195 expect(setInnerHTML).toHaveBeenCalled();
196 var callCountOnMount = setInnerHTML.calls.length;
197
195 - React.render(
198 + ReactDOM.render(
199 <div>
200 <p><span /><span /><span /></p>
201 <p><span /><span /><span /></p>
src/renderers/shared/reconciler/__tests__/ReactMultiChildReconcile-test.js
+7 -6
@@ -14,6 +14,7 @@
14 require('mock-modules');
15
16 var React = require('React');
17 +var ReactDOM = require('ReactDOM');
18 var ReactInstanceMap = require('ReactInstanceMap');
19 var ReactMount = require('ReactMount');
20
@@ -186,7 +187,7 @@ function verifyStatesPreserved(lastInternalStates, statusDisplays) {
187 * accurately reflects what is in the DOM.
188 */
189 function verifyDomOrderingAccurate(parentInstance, statusDisplays) {
189 - var containerNode = React.findDOMNode(parentInstance);
190 + var containerNode = ReactDOM.findDOMNode(parentInstance);
191 var statusDisplayNodes = containerNode.childNodes;
192 var i;
193 var orderedDomIDs = [];
@@ -212,7 +213,7 @@ function verifyDomOrderingAccurate(parentInstance, statusDisplays) {
213 function testPropsSequence(sequence) {
214 var i;
215 var container = document.createElement('div');
215 - var parentInstance = React.render(
216 + var parentInstance = ReactDOM.render(
217 <FriendsStatusDisplay {...sequence[0]} />,
218 container
219 );
@@ -221,7 +222,7 @@ function testPropsSequence(sequence) {
222 verifyStatuses(statusDisplays, sequence[0]);
223
224 for (i = 1; i < sequence.length; i++) {
224 - React.render(
225 + ReactDOM.render(
226 <FriendsStatusDisplay {...sequence[i]} />,
227 container
228 );
@@ -248,7 +249,7 @@ describe('ReactMultiChildReconcile', function() {
249 };
250
251 var container = document.createElement('div');
251 - var parentInstance = React.render(
252 + var parentInstance = ReactDOM.render(
253 <FriendsStatusDisplay {...props} />,
254 container
255 );
@@ -256,7 +257,7 @@ describe('ReactMultiChildReconcile', function() {
257 var startingInternalState = statusDisplays.jcw.getInternalState();
258
259 // Now remove the child.
259 - React.render(
260 + ReactDOM.render(
261 <FriendsStatusDisplay />,
262 container
263 );
@@ -264,7 +265,7 @@ describe('ReactMultiChildReconcile', function() {
265 expect(statusDisplays.jcw).toBeFalsy();
266
267 // Now reset the props that cause there to be a child
267 - React.render(
268 + ReactDOM.render(
269 <FriendsStatusDisplay {...props} />,
270 container
271 );
src/renderers/shared/reconciler/__tests__/ReactMultiChildText-test.js
+4 -3
@@ -14,6 +14,7 @@
14 require('mock-modules');
15
16 var React = require('React');
17 +var ReactDOM = require('ReactDOM');
18 var ReactFragment = require('ReactFragment');
19 var ReactTestUtils = require('ReactTestUtils');
20
@@ -30,17 +31,17 @@ var testAllPermutations = function(testCases) {
31 var expectedResultAfterUpdate = testCases[j + 1];
32
33 var container = document.createElement('div');
33 - var d = React.render(<div>{renderWithChildren}</div>, container);
34 + var d = ReactDOM.render(<div>{renderWithChildren}</div>, container);
35 expectChildren(d, expectedResultAfterRender);
36
36 - d = React.render(<div>{updateWithChildren}</div>, container);
37 + d = ReactDOM.render(<div>{updateWithChildren}</div>, container);
38 expectChildren(d, expectedResultAfterUpdate);
39 }
40 }
41 };
42
43 var expectChildren = function(d, children) {
43 - var outerNode = React.findDOMNode(d);
44 + var outerNode = ReactDOM.findDOMNode(d);
45 var textNode;
46 if (typeof children === 'string') {
47 textNode = outerNode.firstChild;
src/renderers/shared/reconciler/__tests__/ReactUpdates-test.js
+16 -14
@@ -12,12 +12,14 @@
12 'use strict';
13
14 var React;
15 +var ReactDOM;
16 var ReactTestUtils;
17 var ReactUpdates;
18
19 describe('ReactUpdates', function() {
20 beforeEach(function() {
21 React = require('React');
22 + ReactDOM = require('ReactDOM');
23 ReactTestUtils = require('ReactTestUtils');
24 ReactUpdates = require('ReactUpdates');
25 });
@@ -96,12 +98,12 @@ describe('ReactUpdates', function() {
98 });
99
100 var container = document.createElement('div');
99 - var instance = React.render(<Component x={0} />, container);
101 + var instance = ReactDOM.render(<Component x={0} />, container);
102 expect(instance.props.x).toBe(0);
103 expect(instance.state.y).toBe(0);
104
105 ReactUpdates.batchedUpdates(function() {
104 - React.render(<Component x={1} />, container);
106 + ReactDOM.render(<Component x={1} />, container);
107 instance.setState({y: 2});
108 expect(instance.props.x).toBe(0);
109 expect(instance.state.y).toBe(0);
@@ -501,16 +503,16 @@ describe('ReactUpdates', function() {
503
504 // Initial renders aren't batched together yet...
505 ReactUpdates.batchedUpdates(function() {
504 - React.render(<Component text="A1" />, containerA);
505 - React.render(<Component text="B1" />, containerB);
506 + ReactDOM.render(<Component text="A1" />, containerA);
507 + ReactDOM.render(<Component text="B1" />, containerB);
508 });
509 expect(ReconcileTransaction.getPooled.calls.length).toBe(2);
510
511 // ...but updates are! Here only one more transaction is used, which means
512 // we only have to initialize and close the wrappers once.
513 ReactUpdates.batchedUpdates(function() {
512 - React.render(<Component text="A2" />, containerA);
513 - React.render(<Component text="B2" />, containerB);
514 + ReactDOM.render(<Component text="A2" />, containerA);
515 + ReactDOM.render(<Component text="B2" />, containerB);
516 });
517 expect(ReconcileTransaction.getPooled.calls.length).toBe(3);
518 });
@@ -530,7 +532,7 @@ describe('ReactUpdates', function() {
532 return {x: 0};
533 },
534 componentDidUpdate: function() {
533 - expect(React.findDOMNode(b).textContent).toBe('B1');
535 + expect(ReactDOM.findDOMNode(b).textContent).toBe('B1');
536 aUpdated = true;
537 },
538 render: function() {
@@ -641,12 +643,12 @@ describe('ReactUpdates', function() {
643 componentDidMount: function() {
644 instances.push(this);
645 if (this.props.depth < this.props.count) {
644 - React.render(
646 + ReactDOM.render(
647 <MockComponent
648 depth={this.props.depth + 1}
649 count={this.props.count}
650 />,
649 - React.findDOMNode(this)
651 + ReactDOM.findDOMNode(this)
652 );
653 }
654 },
@@ -715,10 +717,10 @@ describe('ReactUpdates', function() {
717
718 x = ReactTestUtils.renderIntoDocument(<X />);
719 y = ReactTestUtils.renderIntoDocument(<Y />);
718 - expect(React.findDOMNode(x).textContent).toBe('0');
720 + expect(ReactDOM.findDOMNode(x).textContent).toBe('0');
721
722 y.forceUpdate();
721 - expect(React.findDOMNode(x).textContent).toBe('1');
723 + expect(ReactDOM.findDOMNode(x).textContent).toBe('1');
724 });
725
726 it('should queue updates from during mount', function() {
@@ -756,7 +758,7 @@ describe('ReactUpdates', function() {
758 });
759
760 expect(a.state.x).toBe(1);
759 - expect(React.findDOMNode(a).textContent).toBe('A1');
761 + expect(ReactDOM.findDOMNode(a).textContent).toBe('A1');
762 });
763
764 it('calls componentWillReceiveProps setState callback properly', function() {
@@ -779,8 +781,8 @@ describe('ReactUpdates', function() {
781 });
782
783 var container = document.createElement('div');
782 - React.render(<A x={1} />, container);
783 - React.render(<A x={2} />, container);
784 + ReactDOM.render(<A x={1} />, container);
785 + ReactDOM.render(<A x={2} />, container);
786 expect(callbackCount).toBe(1);
787 });
788
src/renderers/shared/reconciler/__tests__/refs-destruction-test.js
+6 -4
@@ -12,6 +12,7 @@
12 'use strict';
13
14 var React;
15 +var ReactDOM;
16 var ReactTestUtils;
17
18 var TestComponent;
@@ -21,6 +22,7 @@ describe('refs-destruction', function() {
22 require('mock-modules').dumpCache();
23
24 React = require('React');
25 + ReactDOM = require('ReactDOM');
26 ReactTestUtils = require('ReactTestUtils');
27
28 TestComponent = React.createClass({
@@ -40,21 +42,21 @@ describe('refs-destruction', function() {
42
43 it('should remove refs when destroying the parent', function() {
44 var container = document.createElement('div');
43 - var testInstance = React.render(<TestComponent />, container);
45 + var testInstance = ReactDOM.render(<TestComponent />, container);
46 expect(ReactTestUtils.isDOMComponent(testInstance.refs.theInnerDiv))
47 .toBe(true);
48 expect(Object.keys(testInstance.refs || {}).length).toEqual(1);
47 - React.unmountComponentAtNode(container);
49 + ReactDOM.unmountComponentAtNode(container);
50 expect(Object.keys(testInstance.refs || {}).length).toEqual(0);
51 });
52
53 it('should remove refs when destroying the child', function() {
54 var container = document.createElement('div');
53 - var testInstance = React.render(<TestComponent />, container);
55 + var testInstance = ReactDOM.render(<TestComponent />, container);
56 expect(ReactTestUtils.isDOMComponent(testInstance.refs.theInnerDiv))
57 .toBe(true);
58 expect(Object.keys(testInstance.refs || {}).length).toEqual(1);
57 - React.render(<TestComponent destroy={true} />, container);
59 + ReactDOM.render(<TestComponent destroy={true} />, container);
60 expect(Object.keys(testInstance.refs || {}).length).toEqual(0);
61 });
62 });
src/test/ReactTestUtils.js
+3 -2
@@ -15,6 +15,7 @@ var EventConstants = require('EventConstants');
15 var EventPluginHub = require('EventPluginHub');
16 var EventPropagators = require('EventPropagators');
17 var React = require('React');
18 +var ReactDOM = require('ReactDOM');
19 var ReactElement = require('ReactElement');
20 var ReactEmptyComponent = require('ReactEmptyComponent');
21 var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
@@ -79,7 +80,7 @@ var ReactTestUtils = {
80 // clean up, so we're going to stop honoring the name of this method
81 // (and probably rename it eventually) if no problems arise.
82 // document.documentElement.appendChild(div);
82 - return React.render(instance, div);
83 + return ReactDOM.render(instance, div);
84 },
85
86 isElement: function(element) {
@@ -177,7 +178,7 @@ var ReactTestUtils = {
178 scryRenderedDOMComponentsWithClass: function(root, className) {
179 return ReactTestUtils.findAllInRenderedTree(root, function(inst) {
180 if (ReactTestUtils.isDOMComponent(inst)) {
180 - var instClassName = React.findDOMNode(inst).className;
181 + var instClassName = ReactDOM.findDOMNode(inst).className;
182 return (
183 instClassName &&
184 (('' + instClassName).split(/\s+/)).indexOf(className) !== -1
src/test/__tests__/ReactTestUtils-test.js
+9 -5
@@ -12,6 +12,8 @@
12 'use strict';
13
14 var React;
15 +var ReactDOM;
16 +var ReactDOMServer;
17 var ReactTestUtils;
18
19 var mocks;
@@ -22,6 +24,8 @@ describe('ReactTestUtils', function() {
24 mocks = require('mocks');
25
26 React = require('React');
27 + ReactDOM = require('ReactDOM');
28 + ReactDOMServer = require('ReactDOMServer');
29 ReactTestUtils = require('ReactTestUtils');
30 });
31
@@ -206,14 +210,14 @@ describe('ReactTestUtils', function() {
210 });
211
212 var container = document.createElement('div');
209 - React.render(
213 + ReactDOM.render(
214 <Wrapper>
215 {null}
216 <div>purple</div>
217 </Wrapper>,
218 container
219 );
216 - var tree = React.render(
220 + var tree = ReactDOM.render(
221 <Wrapper>
222 <div>orange</div>
223 <div>purple</div>
@@ -224,7 +228,7 @@ describe('ReactTestUtils', function() {
228 var log = [];
229 ReactTestUtils.findAllInRenderedTree(tree, function(child) {
230 if (ReactTestUtils.isDOMComponent(child)) {
227 - log.push(React.findDOMNode(child).textContent);
231 + log.push(ReactDOM.findDOMNode(child).textContent);
232 }
233 });
234
@@ -298,9 +302,9 @@ describe('ReactTestUtils', function() {
302 },
303 });
304
301 - var markup = React.renderToString(<Root />);
305 + var markup = ReactDOMServer.renderToString(<Root />);
306 var testDocument = getTestDocument(markup);
303 - var component = React.render(<Root />, testDocument);
307 + var component = ReactDOM.render(<Root />, testDocument);
308
309 expect(component.refs.html.tagName).toBe('HTML');
310 expect(component.refs.head.tagName).toBe('HEAD');