@applicaster/zapp-react-native-ui-components
Version:
Applicaster Zapp React Native ui components for the Quick Brick App
45 lines (34 loc) • 1.2 kB
JavaScript
import React from "react";
import TestRenderer from "react-test-renderer";
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 testRenderer = TestRenderer.create(
<CustomImage placeholderImage={"foo"} />
);
const testInstance = testRenderer.root;
expect(testInstance.findByType(Image).props.source).toEqual({
uri: "foo",
});
});
it("Uses provided placeholder image object", () => {
const testRenderer = TestRenderer.create(
<CustomImage placeholderImage={"foo"} />
);
const testInstance = testRenderer.root;
expect(testInstance.findByType(Image).props.source).toEqual({
uri: "foo",
});
});
it("Returns empty string if no image or placeholder defined", () => {
const testRenderer = TestRenderer.create(
<CustomImage placeholderImage={null} />
);
const testInstance = testRenderer.root;
expect(testInstance.findByType(Image).props.source).toEqual({ uri: "" });
});
});