Skip to content
This repository has been archived by the owner on Aug 1, 2018. It is now read-only.

Commit

Permalink
Add a test case for preparing a fragment with async children
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGrandon committed Mar 23, 2018
1 parent 937c456 commit 980f284
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/__tests__/__node__/prepare-render.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,34 @@ tape('Preparing a Fragment', t => {
t.end();
});
});

tape('Preparing a fragment with async children', t => {
let numChildRenders = 0;
let numPrepares = 0;
function SimplePresentational() {
numChildRenders++;
return <div>Hello World</div>;
}
const AsyncChild = prepared(props => {
numPrepares++;
t.equal(
props.data,
'test',
'passes props through to prepared component correctly'
);
return Promise.resolve();
})(SimplePresentational);
const app = (
<React.Fragment>
<AsyncChild data="test" />
<AsyncChild data="test" />
</React.Fragment>
);
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();
});
});

0 comments on commit 980f284

Please sign in to comment.