/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ import React from "react"; import { render, screen } from "@testing-library/react"; import { MemoryRouter } from "react-router-dom"; import ImageWidget from "../ImageWidget"; const imageFile = { type: "image/png", name: "myphoto.png", size: 100, } as File; window.URL.createObjectURL = jest.fn(); test("renders the image title", async () => { render( , { wrapper: MemoryRouter }, ); expect(screen.getByText("test title")).toBeInTheDocument(); }); test("renders the summary below the image", async () => { render( , { wrapper: MemoryRouter }, ); const summary = screen.getByText("test summary"); expect(summary).toBeInTheDocument(); expect(summary.closest("div")).toHaveClass("imageSummaryBelow"); }); test("renders the summary above the image", async () => { render( , { wrapper: MemoryRouter }, ); const summary = screen.getByText("test summary"); expect(summary).toBeInTheDocument(); expect(summary.closest("div")).toHaveClass("imageSummaryAbove"); }); test("image preview should match snapshot", async () => { const wrapper = render( , { wrapper: MemoryRouter }, ); expect(wrapper.container).toMatchSnapshot(); });