mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[tests] assertLog before act in useEffectEvent (#28763)
Fixes tests blocking https://github.com/facebook/react/pull/28737
This commit is contained in:
@@ -742,7 +742,7 @@ describe('useEffectEvent', () => {
|
||||
await act(() =>
|
||||
ReactNoop.render(<ChatRoom roomId="general" theme="light" />),
|
||||
);
|
||||
await act(() => jest.runAllTimers());
|
||||
|
||||
assertLog(['Welcome to the general room!', 'Connected! theme: light']);
|
||||
expect(ReactNoop).toMatchRenderedOutput(
|
||||
<span prop="Welcome to the general room!" />,
|
||||
@@ -752,20 +752,17 @@ describe('useEffectEvent', () => {
|
||||
await act(() =>
|
||||
ReactNoop.render(<ChatRoom roomId="music" theme="light" />),
|
||||
);
|
||||
await act(() => jest.runAllTimers());
|
||||
assertLog([
|
||||
'Welcome to the music room!',
|
||||
// should trigger a reconnect
|
||||
'Connected! theme: light',
|
||||
]);
|
||||
|
||||
expect(ReactNoop).toMatchRenderedOutput(
|
||||
<span prop="Welcome to the music room!" />,
|
||||
);
|
||||
|
||||
// change theme only
|
||||
await act(() => ReactNoop.render(<ChatRoom roomId="music" theme="dark" />));
|
||||
await act(() => jest.runAllTimers());
|
||||
// should not trigger a reconnect
|
||||
assertLog(['Welcome to the music room!']);
|
||||
expect(ReactNoop).toMatchRenderedOutput(
|
||||
@@ -776,7 +773,6 @@ describe('useEffectEvent', () => {
|
||||
await act(() =>
|
||||
ReactNoop.render(<ChatRoom roomId="travel" theme="dark" />),
|
||||
);
|
||||
await act(() => jest.runAllTimers());
|
||||
assertLog([
|
||||
'Welcome to the travel room!',
|
||||
// should trigger a reconnect
|
||||
|
||||
Reference in New Issue
Block a user