-
-
Save marr/afbf41b138102e951af1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TestUtils.renderLightbox = function(dispatcher, lightboxDefn, opt_location, callback) { | |
var Foo = React.createClass({ | |
getChildContext: function() { | |
return { dispatcher: dispatcher }; | |
}, | |
childContextTypes: { | |
dispatcher: React.PropTypes.object.isRequired | |
}, | |
render: function() { | |
var transitions = lightboxDefn.transitions || {}; | |
return React.createElement(LightboxHandler, | |
{ nextTransition: transitions.next, | |
prevTransition: transitions.prev, | |
elem: lightboxDefn.element, | |
elemProps: lightboxDefn.props }); | |
} | |
}); | |
var cb, location; | |
if (typeof opt_location === 'string') { | |
location = new TestLocation([opt_location]); | |
cb = callback; | |
} else { | |
location = new TestLocation(['/']); | |
cb = arguments[2]; | |
} | |
var routes = ( | |
<Router.Route name="default" handler={Foo} path="/" /> | |
); | |
var root; | |
Router.run(routes, location, function(Handler, state) { | |
var root = TestUtils.renderIntoDocument(<Handler {...state} />); | |
cb && cb(root, location); | |
}); | |
return root; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment