Skip to content

Commit

Permalink
Use custom component in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechilds committed Aug 12, 2017
1 parent 0a10dcb commit e5e37a5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/react-jsdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,33 @@ 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(<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');
Expand Down

0 comments on commit e5e37a5

Please sign in to comment.