Skip to content

Commit

Permalink
[tests] assertLog before act in useEffectEvent (#28763)
Browse files Browse the repository at this point in the history
Fixes tests blocking #28737
  • Loading branch information
rickhanlonii authored Apr 10, 2024
1 parent dfc64c6 commit 2243b40
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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!" />,
Expand All @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit 2243b40

Please sign in to comment.