diff --git a/src/__tests__/__node__/prepare-render.node.js b/src/__tests__/__node__/prepare-render.node.js index b7a1239..a5aa595 100644 --- a/src/__tests__/__node__/prepare-render.node.js +++ b/src/__tests__/__node__/prepare-render.node.js @@ -386,3 +386,50 @@ tape('Preparing an async app with componentWillReceiveProps option', t => { t.end(); }); }); + +tape('Preparing a Fragment', t => { + const app = ( + + 1 + 2 + + ); + const p = prepare(app); + t.ok(p instanceof Promise, 'prepare returns a promise'); + p.then(() => { + const wrapper = shallow(
{app}
); + t.equal(wrapper.find('span').length, 2, 'has two children'); + t.end(); + }); +}); + +tape('Preparing a fragment with async children', t => { + let numChildRenders = 0; + let numPrepares = 0; + function SimplePresentational() { + numChildRenders++; + return
Hello World
; + } + const AsyncChild = prepared(props => { + numPrepares++; + t.equal( + props.data, + 'test', + 'passes props through to prepared component correctly' + ); + return Promise.resolve(); + })(SimplePresentational); + const app = ( + + + + + ); + const p = prepare(app); + t.ok(p instanceof Promise, 'prepare returns a promise'); + p.then(() => { + t.equal(numPrepares, 2, 'runs prepare function twice'); + t.equal(numChildRenders, 2, 'renders SimplePresentational twice'); + t.end(); + }); +}); diff --git a/src/prepare.js b/src/prepare.js index 5a756fe..ff89423 100644 --- a/src/prepare.js +++ b/src/prepare.js @@ -41,7 +41,7 @@ function prepareElement(element, context) { return Promise.resolve([null, context]); } const {type, props} = element; - if (typeof type === 'string') { + if (typeof type === 'string' || type === React.Fragment) { return Promise.resolve([props.children, context]); } if (!isReactCompositeComponent(type)) {