Skip to content

Commit f7c6857

Browse files
committed
added react tester based on jsdom
1 parent b291fe0 commit f7c6857

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

utils/tester.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import jsdom from 'jsdom';
2+
import TestUtils from 'react-addons-test-utils';
3+
import React from 'react';
4+
5+
function renderComponent(react, props) {
6+
global.document = jsdom.jsdom('<!DOCTYPE html><html><body></body></html>');
7+
global.window = global.document.parentWindow;
8+
9+
const rendered = TestUtils.renderIntoDocument(React.createElement(react, props));
10+
11+
return TestUtils.findRenderedComponentWithType(rendered, react);
12+
}
13+
14+
export function renderJSX(jsx, context, node) {
15+
return renderComponent(React.createClass({
16+
displayName: 'TestJSX',
17+
render: () => jsx,
18+
}), undefined, context);
19+
}

0 commit comments

Comments
 (0)