Browse Source

Allow any child node type (#10)

master
Francisco Presencia 5 years ago
committed by Luke Childs
parent
commit
fb7da28945
  1. 2
      src/index.js
  2. 20
      test/react-jsdom.js

2
src/index.js

@ -26,7 +26,7 @@ const ReactJSDOM = {
global[prop] = origGlobals[prop];
});
return container.children[0];
return container.childNodes[0];
}
};

20
test/react-jsdom.js

@ -35,6 +35,26 @@ test('ReactJSDOM renders a React Component', t => {
t.is(elem.textContent, 'hi');
});
test('ReactJSDOM renders a React Fragment', t => {
const elem = ReactJSDOM.render((
<React.Fragment><TestComponent/></React.Fragment>
));
t.is(elem.nodeName, 'DIV');
t.is(elem.textContent, 'hi');
});
test('ReactJSDOM renders a Text String', t => {
const elem = ReactJSDOM.render('Hello world');
t.is(elem.nodeName, '#text');
t.is(elem.textContent, 'Hello world');
});
test('ReactJSDOM renders a Fragment wrapping a text string', t => {
const elem = ReactJSDOM.render(<React.Fragment>Hello world</React.Fragment>);
t.is(elem.nodeName, '#text');
t.is(elem.textContent, 'Hello world');
});
test('ReactJSDOM allows window instance to be passed in', t => {
const window = new Window();
const elem = ReactJSDOM.render(<TestComponent/>, window);

Loading…
Cancel
Save