diff --git a/app/javascript/__tests__/pages/listings/ForRent.test.tsx b/app/javascript/__tests__/pages/listings/ForRent.test.tsx index f43b97db5..70053cb31 100644 --- a/app/javascript/__tests__/pages/listings/ForRent.test.tsx +++ b/app/javascript/__tests__/pages/listings/ForRent.test.tsx @@ -19,10 +19,11 @@ jest.mock("../../../hooks/useFeatureFlag", () => ({ useFeatureFlag: jest.fn(), })) +const mockIntersectionObserver = jest.fn() + describe("For Rent", () => { beforeEach(() => { ;(useFeatureFlag as jest.Mock).mockReturnValue({ flagsReady: true, unleashFlag: true }) - const mockIntersectionObserver = jest.fn() mockIntersectionObserver.mockReturnValue({ observe: () => null, }) @@ -40,7 +41,10 @@ describe("For Rent", () => { const { findByText, asFragment } = render() expect(await findByText("Rent affordable housing")).toBeDefined() + ;(await findByText("Enter a lottery")).click() + expect(asFragment()).toMatchSnapshot() + expect(mockIntersectionObserver).toHaveBeenCalled() }) it("listings with multiple listings render the first image in the array", async () => { @@ -63,5 +67,6 @@ describe("For Rent", () => { const image = await findByAltText("This is a listing image") expect(image.getAttribute("src")).toBe(sroRentalListing.Listing_Images[0].displayImageURL) + expect(mockIntersectionObserver).toHaveBeenCalled() }) })