[Suspense] Add Batched Mode variant to fuzz tester (#15734)

This commit is contained in:
Andrew Clark
2019-05-28 11:41:01 -07:00
committed by GitHub
parent 7c5645ddb1
commit d915a4c1f1
2 changed files with 16 additions and 13 deletions
+2 -2
View File
@@ -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);
},
};
},
@@ -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);
@@ -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 concurrentOutput = ReactNoop.getChildrenAsJSX('concurrent');
const batchedSyncOutput = batchedSyncRoot.getChildrenAsJSX();
expect(batchedSyncOutput).toEqual(expectedOutput);
resetCache();
const concurrentRoot = ReactNoop.createRoot();
concurrentRoot.render(children);
resolveAllTasks();
const concurrentOutput = concurrentRoot.getChildrenAsJSX();
expect(concurrentOutput).toEqual(expectedOutput);
ReactNoop.renderToRootWithID(null, 'concurrent');
Scheduler.unstable_flushWithoutYielding();
}
function pickRandomWeighted(rand, options) {
@@ -321,7 +324,7 @@ describe('ReactSuspenseFuzz', () => {
);
});
it('generative tests', () => {
it(`generative tests (random seed: ${SEED})`, () => {
const {generateTestCase, testResolvedOutput} = createFuzzer();
const rand = Random.create(SEED);