Skip to content

Commit

Permalink
Update test comments with explanations
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Jul 13, 2021
1 parent 87b67d3 commit bff5fe5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ describe('ReactHooksWithNoopRenderer', () => {
// Schedule some updates
if (gate(flags => flags.enableSyncDefaultUpdates)) {
React.startTransition(() => {
// TODO: Batched updates need to be inside startTransition?
ReactNoop.batchedUpdates(() => {
counter.current.updateCount(1);
counter.current.updateCount(count => count + 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,12 @@ describe('ReactIncrementalScheduling', () => {
instance.setState({tick: 2});
});

// TODO: why does this flush sync?
expect(Scheduler).toFlushAndYieldThrough([
'render: 2',
'componentDidUpdate: 2',
'componentDidUpdate (before setState): 2',
'componentDidUpdate (after setState): 2',
// This renders because the scheduled update is default, which is sync.
'render: 3',
'componentDidUpdate: 3',
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,13 @@ describe('ReactIncrementalUpdates', () => {
// Now flush the remaining work. Even though e and f were already processed,
// they should be processed again, to ensure that the terminal state
// is deterministic.
// TODO: should d, e, f be flushed again first?
expect(Scheduler).toFlushAndYield([
// Since 'g' is in a transition, we'll process 'd' separately first.
// That causes us to process 'd' with 'e' and 'f' rebased.
'd',
'e',
'f',
// Then we'll re-process everything for 'g'.
'a',
'b',
'c',
Expand Down Expand Up @@ -290,18 +292,19 @@ describe('ReactIncrementalUpdates', () => {
});

// The sync updates should have flushed, but not the async ones.
// TODO: should 'd' have flushed?
// TODO: should 'f' have flushed? I don't know what enqueueReplaceState is.
expect(Scheduler).toHaveYielded(['e', 'f']);
expect(ReactNoop.getChildren()).toEqual([span('f')]);

// Now flush the remaining work. Even though e and f were already processed,
// they should be processed again, to ensure that the terminal state
// is deterministic.
expect(Scheduler).toFlushAndYield([
// Since 'g' is in a transition, we'll process 'd' separately first.
// That causes us to process 'd' with 'e' and 'f' rebased.
'd',
'e',
'f',
// Then we'll re-process everything for 'g'.
'a',
'b',
'c',
Expand Down

0 comments on commit bff5fe5

Please sign in to comment.