Skip to content

Commit

Permalink
test: DAH-2661 add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tallulahkay committed Dec 19, 2024
1 parent 6fe1ce6 commit bb86970
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/javascript/__tests__/pages/listings/ForRent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand All @@ -40,7 +41,10 @@ describe("For Rent", () => {
const { findByText, asFragment } = render(<ForRent assetPaths="/" />)

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 () => {
Expand All @@ -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()
})
})

0 comments on commit bb86970

Please sign in to comment.