Skip to content

Commit

Permalink
Revert "Add regression test for #18497 (#18538)" (#19215)
Browse files Browse the repository at this point in the history
This reverts commit e9c1445.
  • Loading branch information
gaearon committed Jun 30, 2020
1 parent b621dab commit 47ff31a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 43 deletions.
Expand Up @@ -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]');
});
});
});
4 changes: 1 addition & 3 deletions scripts/jest/matchers/schedulerTestMatchers.js
Expand Up @@ -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.'
);
}
Expand Down

0 comments on commit 47ff31a

Please sign in to comment.