|
|
@ -3,6 +3,12 @@ import Window from 'window'; |
|
|
|
import React from 'react'; |
|
|
|
import ReactJSDOM from 'this'; |
|
|
|
|
|
|
|
class TestComponent extends React.Component { |
|
|
|
render() { |
|
|
|
return <div>hi</div>; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
test('ReactJSDOM is a object', t => { |
|
|
|
t.is(typeof ReactJSDOM, 'object'); |
|
|
|
}); |
|
|
@ -10,20 +16,20 @@ test('ReactJSDOM is a object', t => { |
|
|
|
test('ReactJSDOM cleans up globals', t => { |
|
|
|
global.window = 'foo'; |
|
|
|
global.document = 'bar'; |
|
|
|
ReactJSDOM.render(<div>hi</div>); |
|
|
|
ReactJSDOM.render(<TestComponent/>); |
|
|
|
t.is(global.window, 'foo'); |
|
|
|
t.is(global.document, 'bar'); |
|
|
|
}); |
|
|
|
|
|
|
|
test('ReactJSDOM renders a React Component', t => { |
|
|
|
const elem = ReactJSDOM.render(<div>hi</div>); |
|
|
|
const elem = ReactJSDOM.render(<TestComponent/>); |
|
|
|
t.is(elem.nodeName, 'DIV'); |
|
|
|
t.is(elem.textContent, 'hi'); |
|
|
|
}); |
|
|
|
|
|
|
|
test('ReactJSDOM allows window instance to be passed in', t => { |
|
|
|
const window = new Window(); |
|
|
|
const elem = ReactJSDOM.render(<div>hi</div>, window); |
|
|
|
const elem = ReactJSDOM.render(<TestComponent/>, window); |
|
|
|
t.is(elem, window.document.getElementById('root').children[0]); |
|
|
|
t.is(elem.nodeName, 'DIV'); |
|
|
|
t.is(elem.textContent, 'hi'); |
|
|
|