import React, { createRef } from "react"; import { act, render, screen, userEvent, waitFor, } from "@testing-library/react-native"; import { AccessibilityInfo, View } from "react-native"; import type { ReactTestInstance } from "react-test-renderer"; import type { ContentOverlayRef, ModalBackgroundColor } from "./types"; import { ContentOverlay } from "./ContentOverlay"; import { AtlantisOverlayProvider } from "../AtlantisOverlayProvider"; import { tokens } from "../utils/design"; import { Button } from "../Button"; import { Content } from "../Content"; import { Text } from "../Text"; jest.unmock("../hooks/useIsScreenReaderEnabled"); jest.unmock("react-native-reanimated"); jest.unmock("@gorhom/bottom-sheet"); jest.mock("@gorhom/bottom-sheet/lib/commonjs/hooks/useAnimatedLayout", () => ({ // Fix for reanimated not actually running in the test environment. useAnimatedLayout: () => { const value = { containerHeight: 600, rawContainerHeight: 600, handleHeight: 24, footerHeight: 0, contentHeight: 400, containerOffset: { top: 0, bottom: 0, left: 0, right: 0 }, }; return { value, get: () => value }; }, })); const user = userEvent.setup(); interface testRendererOptions { text: string; title: string; buttonLabel: string; a11yLabel?: string; fullScreen?: boolean; showDismiss?: boolean; modalBackgroundColor?: ModalBackgroundColor; onCloseCallback?: () => void; onOpenCallback?: () => void; onBeforeExitCallback?: () => void; } function getDefaultOptions(): testRendererOptions { return { text: "I am the contentOverlay text", title: "Title", buttonLabel: "Open Content Overlay", fullScreen: false, showDismiss: false, modalBackgroundColor: "surface", }; } function renderContentOverlay( { text, title, buttonLabel, a11yLabel, fullScreen, showDismiss, modalBackgroundColor, onCloseCallback, onOpenCallback, onBeforeExitCallback, }: Partial = getDefaultOptions(), ) { const contentOverlayRef = createRef(); render( I am a bunch of text