UNPKG

@applicaster/zapp-react-native-ui-components

Version:

Applicaster Zapp React Native ui components for the Quick Brick App

45 lines (34 loc) 1.17 kB
import React from "react"; import { render } from "@testing-library/react-native"; import { Image } from "react-native"; jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({ useTheme: () => ({}), })); const CustomImage = require("../Image").default; describe("image with no source", () => { it("Uses provided placeholder image string", () => { const { UNSAFE_getByType } = render( <CustomImage placeholderImage={"foo"} /> ); const imageComponent = UNSAFE_getByType(Image); expect(imageComponent.props.source).toEqual({ uri: "foo", }); }); it("Uses provided placeholder image object", () => { const { UNSAFE_getByType } = render( <CustomImage placeholderImage={"foo"} /> ); const imageComponent = UNSAFE_getByType(Image); expect(imageComponent.props.source).toEqual({ uri: "foo", }); }); it("Returns empty string if no image or placeholder defined", () => { const { UNSAFE_getByType } = render( <CustomImage placeholderImage={null} /> ); const imageComponent = UNSAFE_getByType(Image); expect(imageComponent.props.source).toBeUndefined(); }); });