|
@ -10,27 +10,20 @@ test('ReactJSDOM is a object', t => { |
|
|
test('ReactJSDOM cleans up globals', t => { |
|
|
test('ReactJSDOM cleans up globals', t => { |
|
|
global.window = 'foo'; |
|
|
global.window = 'foo'; |
|
|
global.document = 'bar'; |
|
|
global.document = 'bar'; |
|
|
ReactJSDOM.render( |
|
|
ReactJSDOM.render(<div>hi</div>); |
|
|
React.createElement('div', {}, 'hi') |
|
|
|
|
|
); |
|
|
|
|
|
t.is(global.window, 'foo'); |
|
|
t.is(global.window, 'foo'); |
|
|
t.is(global.document, 'bar'); |
|
|
t.is(global.document, 'bar'); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
test('ReactJSDOM renders a React Component', t => { |
|
|
test('ReactJSDOM renders a React Component', t => { |
|
|
const elem = ReactJSDOM.render( |
|
|
const elem = ReactJSDOM.render(<div>hi</div>); |
|
|
React.createElement('div', {}, 'hi') |
|
|
|
|
|
); |
|
|
|
|
|
t.is(elem.nodeName, 'DIV'); |
|
|
t.is(elem.nodeName, 'DIV'); |
|
|
t.is(elem.textContent, 'hi'); |
|
|
t.is(elem.textContent, 'hi'); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
test('ReactJSDOM allows window instance to be passed in', t => { |
|
|
test('ReactJSDOM allows window instance to be passed in', t => { |
|
|
const window = new Window(); |
|
|
const window = new Window(); |
|
|
const elem = ReactJSDOM.render( |
|
|
const elem = ReactJSDOM.render(<div>hi</div>, window); |
|
|
React.createElement('div', {}, 'hi'), |
|
|
|
|
|
window |
|
|
|
|
|
); |
|
|
|
|
|
t.is(elem, window.document.getElementById('root').children[0]); |
|
|
t.is(elem, window.document.getElementById('root').children[0]); |
|
|
t.is(elem.nodeName, 'DIV'); |
|
|
t.is(elem.nodeName, 'DIV'); |
|
|
t.is(elem.textContent, 'hi'); |
|
|
t.is(elem.textContent, 'hi'); |
|
|