Skip to content

Commit

Permalink
[Suspense] Add Batched Mode variant to fuzz tester (facebook#15734)
Browse files Browse the repository at this point in the history
  • Loading branch information
acdlite authored May 28, 2019
1 parent 7c5645d commit d915a4c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/react-noop-renderer/src/createReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,10 +969,10 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
NoopRenderer.updateContainer(children, fiberRoot, null, null);
},
getChildren() {
return getChildren(fiberRoot);
return getChildren(container);
},
getChildrenAsJSX() {
return getChildrenAsJSX(fiberRoot);
return getChildrenAsJSX(container);
},
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,14 @@ describe('ReactSuspenseFuzz', () => {
);

resetCache();
ReactNoop.renderToRootWithID(
const expectedRoot = ReactNoop.createRoot();
expectedRoot.render(
<ShouldSuspendContext.Provider value={false}>
{children}
</ShouldSuspendContext.Provider>,
'expected',
);
resolveAllTasks();
const expectedOutput = ReactNoop.getChildrenAsJSX('expected');
ReactNoop.renderToRootWithID(null, 'expected');
Scheduler.unstable_flushWithoutYielding();
const expectedOutput = expectedRoot.getChildrenAsJSX();

resetCache();
ReactNoop.renderLegacySyncRoot(children);
Expand All @@ -179,13 +177,18 @@ describe('ReactSuspenseFuzz', () => {
ReactNoop.renderLegacySyncRoot(null);

resetCache();
ReactNoop.renderToRootWithID(children, 'concurrent');
Scheduler.unstable_flushWithoutYielding();
const batchedSyncRoot = ReactNoop.createSyncRoot();
batchedSyncRoot.render(children);
resolveAllTasks();
const batchedSyncOutput = batchedSyncRoot.getChildrenAsJSX();
expect(batchedSyncOutput).toEqual(expectedOutput);

resetCache();
const concurrentRoot = ReactNoop.createRoot();
concurrentRoot.render(children);
resolveAllTasks();
const concurrentOutput = ReactNoop.getChildrenAsJSX('concurrent');
const concurrentOutput = concurrentRoot.getChildrenAsJSX();
expect(concurrentOutput).toEqual(expectedOutput);
ReactNoop.renderToRootWithID(null, 'concurrent');
Scheduler.unstable_flushWithoutYielding();
}

function pickRandomWeighted(rand, options) {
Expand Down Expand Up @@ -321,7 +324,7 @@ describe('ReactSuspenseFuzz', () => {
);
});

it('generative tests', () => {
it(`generative tests (random seed: ${SEED})`, () => {
const {generateTestCase, testResolvedOutput} = createFuzzer();

const rand = Random.create(SEED);
Expand Down

0 comments on commit d915a4c

Please sign in to comment.