Revert "Add regression test for #18497 (#18538)"

This reverts commit e9c1445ba0.
This commit is contained in:
Dan Abramov 2020-06-30 13:38:00 +01:00 committed by GitHub
parent b621dab5d4
commit 18fb4d3276
2 changed files with 1 additions and 43 deletions

View File

@ -3314,44 +3314,4 @@ describe('ReactHooksWithNoopRenderer', () => {
});
expect(ReactNoop).toMatchRenderedOutput('ABC');
});
it('keeps intermediate state updates (issue #18497)', () => {
let _dispatch;
function Counter() {
const [list, dispatch] = React.useReducer((l, c) => l.concat([c]), []);
_dispatch = dispatch;
const json = JSON.stringify(list);
Scheduler.unstable_yieldValue('Render ' + json);
useLayoutEffect(() => {
Scheduler.unstable_yieldValue('Commit ' + json);
});
return json;
}
act(() => {
ReactNoop.render(<Counter />);
expect(Scheduler).toFlushAndYieldThrough(['Render []', 'Commit []']);
expect(ReactNoop).toMatchRenderedOutput('[]');
});
act(() => {
_dispatch(1);
expect(Scheduler).toFlushAndYieldThrough(['Render [1]']);
_dispatch(2);
expect(Scheduler).toFlushAndYieldThrough(['Commit [1]']);
expect(ReactNoop).toMatchRenderedOutput('[1]');
expect(Scheduler).toFlushAndYieldThrough(['Render [1,2]']);
_dispatch(3);
expect(Scheduler).toFlushAndYieldThrough([
'Render [1,2,3]',
'Commit [1,2,3]',
]);
expect(ReactNoop).toMatchRenderedOutput('[1,2,3]');
});
});
});

View File

@ -20,9 +20,7 @@ function assertYieldsWereCleared(Scheduler) {
const actualYields = Scheduler.unstable_clearYields();
if (actualYields.length !== 0) {
throw new Error(
'Log of yielded values is not empty: ' +
JSON.stringify(actualYields) +
'. ' +
'Log of yielded values is not empty. ' +
'Call expect(Scheduler).toHaveYielded(...) first.'
);
}