Created
March 16, 2016 00:02
-
-
Save sirbrillig/6314394fdf495c9957a9 to your computer and use it in GitHub Desktop.
This file should run, but it throws an error
This file contains hidden or 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
// Set up DOM | |
var jsdom = require( 'jsdom' ).jsdom; | |
global.document = jsdom( '' ); | |
global.window = document.defaultView; | |
global.navigator = document.defaultView.navigator; | |
// Prepare React | |
var ReactTestUtils = require( 'react-addons-test-utils' ); | |
var React = require( 'react' ); | |
var Frame = React.createClass( { | |
componentDidMount() { | |
console.log( 'iframe loaded. adding content' ); | |
const iframe = this.refs.iframe; | |
console.log( 'adding content to', iframe.contentWindow ); // Should not be null | |
iframe.contentWindow.document.open(); | |
iframe.contentWindow.document.write( 'Hello World!' ); | |
iframe.contentWindow.document.close(); | |
}, | |
render() { | |
console.log( 'rendering iframe' ); | |
return React.createElement( 'iframe', { ref: 'iframe' } ); | |
} | |
} ); | |
// Render the component | |
ReactTestUtils.renderIntoDocument( React.createElement( Frame ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment