import React from "react"; import { Animated } from "react-native"; import { render } from "@testing-library/react-native"; jest.mock( "@applicaster/zapp-react-native-ui-components/Components/BackgroundImage", () => { const { Text } = require("react-native"); return { BackgroundImage: () => ( BackgroundImage ), }; } ); import { Overlay } from "../Overlay"; const flattenStyle = (style: unknown): Record => { if (!style) { return {}; } if (Array.isArray(style)) { return style.reduce>( (acc, item) => ({ ...acc, ...flattenStyle(item) }), {} ); } if (typeof style === "object") { return style as Record; } return {}; }; describe("Overlay", () => { it("renders the animated overlay container", () => { const opacity = new Animated.Value(1); const { getByTestId } = render( ); expect(getByTestId("animated-component")).toBeTruthy(); }); it("applies opacity and backgroundColor to the overlay", () => { const opacity = new Animated.Value(0.5); const { getByTestId } = render( ); const style = flattenStyle(getByTestId("animated-component").props.style); expect(style.backgroundColor).toBe("#ff0000"); expect(style.opacity).toBe(0.5); }); it("positions the overlay with absolute fill layout", () => { const opacity = new Animated.Value(1); const { getByTestId } = render( ); const style = flattenStyle(getByTestId("animated-component").props.style); expect(style.position).toBe("absolute"); expect(style.top).toBe(0); expect(style.left).toBe(0); expect(style.right).toBe(0); expect(style.bottom).toBe(0); }); it("renders BackgroundImage inside the overlay", () => { const opacity = new Animated.Value(1); const { getByTestId } = render( ); expect(getByTestId("background-image")).toBeTruthy(); }); });