Skip to content

Commit

Permalink
Replaced document.createElement with ReactTestUtils.renderIntoDocumen…
Browse files Browse the repository at this point in the history
…t where container was not subsequently utilized.

Fixes facebook#1250
  • Loading branch information
jimfb committed Nov 25, 2014
1 parent e18d87b commit 89fafad
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 32 deletions.
5 changes: 3 additions & 2 deletions src/addons/link/__tests__/LinkedStateMixin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ describe('LinkedStateMixin', function() {
var LinkedStateMixin;
var React;
var ReactLink;
var ReactTestUtils;

beforeEach(function() {
LinkedStateMixin = require('LinkedStateMixin');
React = require('React');
ReactLink = require('ReactLink');
ReactTestUtils = require('ReactTestUtils');
});

it('should create a ReactLink for state', function() {
Expand All @@ -36,8 +38,7 @@ describe('LinkedStateMixin', function() {
return <span>value is {this.state.value}</span>;
}
});
var container = document.createElement('div');
var component = React.render(<Component />, container);
var component = ReactTestUtils.renderIntoDocument(<Component />);
var link = component.linkState('value');
expect(component.state.value).toBe('initial value');
expect(link.value).toBe('initial value');
Expand Down
5 changes: 3 additions & 2 deletions src/browser/ui/__tests__/ReactEventListener-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('ReactEventListener', function() {

var ReactMount;
var ReactEventListener;
var ReactTestUtils;
var handleTopLevel;

beforeEach(function() {
Expand All @@ -29,6 +30,7 @@ describe('ReactEventListener', function() {

ReactMount = require('ReactMount');
ReactEventListener = require('ReactEventListener');
ReactTestUtils = require('ReactTestUtils');

handleTopLevel = mocks.getMockFunction();
ReactEventListener._handleTopLevel = handleTopLevel;
Expand Down Expand Up @@ -158,7 +160,6 @@ describe('ReactEventListener', function() {
});

it('should not fire duplicate events for a React DOM tree', function() {
var container = document.createElement('div');
var Wrapper = React.createClass({

getInner: function() {
Expand All @@ -172,7 +173,7 @@ describe('ReactEventListener', function() {

});

var instance = ReactMount.render(<Wrapper />, container);
var instance = ReactTestUtils.renderIntoDocument(<Wrapper />);

var callback = ReactEventListener.dispatchEvent.bind(null, 'test');
callback({
Expand Down
6 changes: 2 additions & 4 deletions src/browser/ui/dom/components/__tests__/ReactDOMInput-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,10 @@ describe('ReactDOMInput', function() {
});

it('should support ReactLink', function() {
var container = document.createElement('div');
var link = new ReactLink('yolo', mocks.getMockFunction());
var instance = <input type="text" valueLink={link} />;

instance = React.render(instance, container);
instance = ReactTestUtils.renderIntoDocument(instance);

expect(instance.getDOMNode().value).toBe('yolo');
expect(link.value).toBe('yolo');
Expand Down Expand Up @@ -274,11 +273,10 @@ describe('ReactDOMInput', function() {
});

it('should support checkedLink', function() {
var container = document.createElement('div');
var link = new ReactLink(true, mocks.getMockFunction());
var instance = <input type="checkbox" checkedLink={link} />;

instance = React.render(instance, container);
instance = ReactTestUtils.renderIntoDocument(instance);

expect(instance.getDOMNode().checked).toBe(true);
expect(link.value).toBe(true);
Expand Down
6 changes: 2 additions & 4 deletions src/core/__tests__/ReactComponentLifeCycle-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,8 @@ describe('ReactComponentLifeCycle', function() {
}
});

var container = document.createElement('div');
var instance = React.render(
<Component text="uno" tooltipText="one" />,
container
var instance = ReactTestUtils.renderIntoDocument(
<Component text="uno" tooltipText="one" />
);

// Since `instance` is a root component, we can set its props. This also
Expand Down
8 changes: 4 additions & 4 deletions src/core/__tests__/ReactIdentity-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe('ReactIdentity', function() {

expect(function() {

React.render(<TestContainer />, document.createElement('div'));
ReactTestUtils.renderIntoDocument(<TestContainer />);

}).not.toThrow();
});
Expand Down Expand Up @@ -218,7 +218,7 @@ describe('ReactIdentity', function() {

expect(function() {

React.render(<TestContainer />, document.createElement('div'));
ReactTestUtils.renderIntoDocument(<TestContainer />);

}).not.toThrow();
});
Expand All @@ -245,7 +245,7 @@ describe('ReactIdentity', function() {

expect(function() {

React.render(<TestContainer />, document.createElement('div'));
ReactTestUtils.renderIntoDocument(<TestContainer />);

}).not.toThrow();
});
Expand Down Expand Up @@ -304,7 +304,7 @@ describe('ReactIdentity', function() {
</div>;

expect(function() {
React.render(component, document.createElement('div'));
ReactTestUtils.renderIntoDocument(component);
}).not.toThrow();
});

Expand Down
13 changes: 4 additions & 9 deletions src/core/__tests__/ReactMultiChildText-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,23 +214,18 @@ describe('ReactMultiChildText', function() {
});

it('should render between nested components and inline children', function() {
var container = document.createElement('div');
React.render(<div><h1><span /><span /></h1></div>, container);
ReactTestUtils.renderIntoDocument(<div><h1><span /><span /></h1></div>);

expect(function() {
React.render(<div><h1>A</h1></div>, container);
ReactTestUtils.renderIntoDocument(<div><h1>A</h1></div>);
}).not.toThrow();

React.render(<div><h1><span /><span /></h1></div>, container);

expect(function() {
React.render(<div><h1>{['A']}</h1></div>, container);
ReactTestUtils.renderIntoDocument(<div><h1>{['A']}</h1></div>);
}).not.toThrow();

React.render(<div><h1><span /><span /></h1></div>, container);

expect(function() {
React.render(<div><h1>{['A', 'B']}</h1></div>, container);
ReactTestUtils.renderIntoDocument(<div><h1>{['A', 'B']}</h1></div>);
}).not.toThrow();
});
});
10 changes: 3 additions & 7 deletions src/core/__tests__/ReactUpdates-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,7 @@ describe('ReactUpdates', function() {
}
});

var container = document.createElement('div');
var component = React.render(<A />, container);
var component = ReactTestUtils.renderIntoDocument(<A />);
component.forceUpdate();
expect(callbackCount).toBe(2);
});
Expand Down Expand Up @@ -832,8 +831,7 @@ describe('ReactUpdates', function() {
}
});

var container = document.createElement('div');
var component = React.render(<A />, container);
var component = ReactTestUtils.renderIntoDocument(<A />);
component.setState({updates: 1});
expect(log).toEqual([
'render-0',
Expand Down Expand Up @@ -880,9 +878,7 @@ describe('ReactUpdates', function() {
}
});

var container = document.createElement('div');

var component = React.render(<A />, container);
var component = ReactTestUtils.renderIntoDocument(<A />);

ReactUpdates.batchedUpdates(function() {
// B will have scheduled an update but the batching should ensure that its
Expand Down

0 comments on commit 89fafad

Please sign in to comment.