Skip to content

Commit

Permalink
Failing test: Updates "un-committed" when rebasing
Browse files Browse the repository at this point in the history
Adds a failing test case where an update that was committed is
later skipped over during a rebase. This should never happen.
  • Loading branch information
acdlite committed Nov 21, 2019
1 parent 54f6673 commit 4a1e6eb
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -653,4 +653,48 @@ describe('ReactIncrementalUpdates', () => {
expect(Scheduler).toFlushAndYield(['Commit: goodbye']);
});
});

it('when rebasing, does not exclude updates that were already committed, regardless of priority', async () => {
const {useState, useLayoutEffect} = React;

let pushToLog;
function App() {
const [log, setLog] = useState('');
pushToLog = msg => {
setLog(prevLog => (prevLog += msg));
};

useLayoutEffect(
() => {
Scheduler.unstable_yieldValue('Committed: ' + log);
if (log === 'B') {
setLog(prevLog => (prevLog += 'C'));
}
},
[log],
);

return log;
}

const root = ReactNoop.createRoot();
await ReactNoop.act(async () => {
root.render(<App />);
});
expect(Scheduler).toHaveYielded(['Committed: ']);
expect(root).toMatchRenderedOutput('');

await ReactNoop.act(async () => {
pushToLog('A');
ReactNoop.discreteUpdates(() => {
pushToLog('B');
});
});
expect(Scheduler).toHaveYielded([
'Committed: B',
'Committed: BC',
'Committed: ABC',
]);
expect(root).toMatchRenderedOutput('ABC');
});
});

0 comments on commit 4a1e6eb

Please sign in to comment.