Skip to content

Commit

Permalink
fixed frontend test
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-pohl committed Jun 4, 2024
1 parent 8e50668 commit 89ab047
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import {render, screen} from '@testing-library/react';
import '@testing-library/jest-dom';
import RestaurantCard from "./RestaurantCard.tsx";
import {RestaurantType} from "../../model/Restaurant.ts";
import {BrowserRouter} from "react-router-dom";

test('RestaurantCard component displays title of the restaurant', () => {
const restaurant: RestaurantType = {id: "1", title: "Don Carlos", city: "Berlin"}
render(<RestaurantCard restaurant={restaurant}/>);
render(<BrowserRouter><RestaurantCard restaurant={restaurant}/></BrowserRouter>);
const restaurantTitle = screen.getByText(/Don Carlos/i);
expect(restaurantTitle).toBeInTheDocument();
});

test("RestaurantCard component displays the title of the restaurant as h2", () => {
const restaurant: RestaurantType = {id: "1", title: "Don Carlos", city: "Berlin"}
render(<RestaurantCard restaurant={restaurant}/>);
render(<BrowserRouter><RestaurantCard restaurant={restaurant}/></BrowserRouter>);
const restaurantTitle = screen.getByRole("heading", {
level: 2,
name: /don carlos/i
Expand All @@ -22,7 +23,7 @@ test("RestaurantCard component displays the title of the restaurant as h2", () =

test("RestaurantCard component displays the city", () => {
const restaurant: RestaurantType = {id: "1", title: "Don Carlos", city: "Berlin"}
render(<RestaurantCard restaurant={restaurant}/>);
render(<BrowserRouter><RestaurantCard restaurant={restaurant}/></BrowserRouter>);
const restaurantCity = screen.getByText(/Berlin/i);
expect(restaurantCity).toBeInTheDocument();
})

0 comments on commit 89ab047

Please sign in to comment.