Skip to content

Commit

Permalink
Wrap test in act (#3305)
Browse files Browse the repository at this point in the history
* Wrap test in act

* Test updating act
  • Loading branch information
mattupham authored Jun 6, 2024
1 parent bc19f28 commit f8461a1
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { screen } from "@testing-library/react";
import { act, screen } from "@testing-library/react";

import { renderWithProviders } from "~/__tests__/test-utils";
import { SwapAdBannerResponse } from "~/pages";
Expand All @@ -21,7 +21,10 @@ test("renders ad banner content correctly", () => {
featured: true,
};

renderWithProviders(<AdBannerContent {...mockAd} localization={{}} />);
act(() => {
renderWithProviders(<AdBannerContent {...mockAd} localization={{}} />);
});

const headerElement = screen.getByText(mockAd.headerOrTranslationKey);
const subheaderElement = screen.getByText(mockAd.subheaderOrTranslationKey);
const imageElement = screen.getByAltText(mockAd.iconImageAltOrTranslationKey);
Expand Down Expand Up @@ -62,12 +65,15 @@ test("renders ad banner content with localization correctly", () => {

const ad = mockAdResponseWithLocalization.banners[0];

renderWithProviders(
<AdBannerContent
{...ad}
localization={mockAdResponseWithLocalization.localization}
/>
);
act(() => {
renderWithProviders(
<AdBannerContent
{...ad}
localization={mockAdResponseWithLocalization.localization}
/>
);
});

const headerElement = screen.getByText("Mock Header");
const subheaderElement = screen.getByText("Mock Subheader");
const imageElement = screen.getByAltText("Mock Icon");
Expand Down

0 comments on commit f8461a1

Please sign in to comment.