All files testlib.js

100% Statements 12/12
100% Branches 0/0
100% Functions 3/3
100% Lines 12/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 231x 1x 1x   1x   1x   1x         2x 2x 2x 2x 2x       1x  
var jsdom = require('jsdom').jsdom;
var React = require('react');
var TestUtils = require('react-addons-test-utils');
 
var Testlib = {
    renderJSX: function (jsx, context) {
        return Testlib.renderComponent(React.createClass({
            displayName: 'TestJSX',
            render: function () {return jsx;}
        }), undefined, context);
    },
    renderComponent: function (react, props) {
        var rendered;
        global.document = jsdom('<!DOCTYPE html><html><body></body></html>');
        global.window = global.document.defaultView;
        global.navigator = window.navigator;
        rendered = TestUtils.renderIntoDocument(React.createElement(react, props));
        return TestUtils.findRenderedComponentWithType(rendered, react);
    }
};
 
module.exports = Testlib;