You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
927 B
36 lines
927 B
import test from 'ava';
|
|
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');
|
|
});
|
|
|
|
test('ReactJSDOM cleans up globals', t => {
|
|
global.window = 'foo';
|
|
global.document = 'bar';
|
|
ReactJSDOM.render(<TestComponent/>);
|
|
t.is(global.window, 'foo');
|
|
t.is(global.document, 'bar');
|
|
});
|
|
|
|
test('ReactJSDOM renders a React Component', t => {
|
|
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(<TestComponent/>, window);
|
|
t.is(elem, window.document.getElementById('root').children[0]);
|
|
t.is(elem.nodeName, 'DIV');
|
|
t.is(elem.textContent, 'hi');
|
|
});
|
|
|