Movie_Search/movie-search/__tests__/MovieCard.test.jsx
2024-06-02 01:21:21 -04:00

24 lines
810 B
JavaScript

import "@testing-library/jest-dom";
import { render, screen } from "@testing-library/react";
import MovieCard from "../src/common/components/MovieCard.tsx";
const movie = {
Title: "Dune",
Year: "2000",
imdbID: "tt0142032",
Type: "series",
Poster:
"https://m.media-amazon.com/images/M/MV5BMTU4MjMyMTkxN15BMl5BanBnXkFtZTYwODA5OTU5._V1_SX300.jpg",
};
describe("MovieCard Rendering", () => {
test("should render with Dune title.", () => {
render(<MovieCard movie={movie} />);
const movieTitle = screen.getByRole("heading");
expect(movieTitle).toHaveTextContent("Dune");
});
test("should render with Year 2000.", () => {
render(<MovieCard movie={movie} />);
const movieTitle = screen.getByTestId("MovieCard-Year");
expect(movieTitle).toHaveTextContent("2000");
});
});