Skip to content

Replaced document.createElement with ReactTestUtil #2597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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