UNPKG

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

Version:

Applicaster Zapp React Native ui components for the Quick Brick App

28 lines (21 loc) 788 B
import { renderHook } from "@testing-library/react-hooks"; import { Image } from "react-native"; import { useGetImageDimensions } from "../useGetImageDimensions"; import { getDimension } from "../utils"; const WIDTH = 100; const HEIGTH = 50; jest.spyOn(Image, "getSize").mockImplementation((_uri, success) => { success(WIDTH, HEIGTH); }); describe("useGetImageDimensions", () => { it("should return aspect ration initially when known dimensions", async () => { const { result, waitForNextUpdate } = renderHook(() => useGetImageDimensions("https://some_url.com", WIDTH, undefined) ); expect(result.current).toBeUndefined(); await waitForNextUpdate(); expect(result.current).toEqual( getDimension({ width: WIDTH, height: HEIGTH }) ); }); });