diff --git a/src/components/Card/__test__/card.test.jsx b/src/components/Card/__test__/card.test.jsx new file mode 100644 index 0000000..193ed37 --- /dev/null +++ b/src/components/Card/__test__/card.test.jsx @@ -0,0 +1,31 @@ +import Card from "../Card"; +import { render, screen } from "@testing-library/react"; + +test("should render a title", () => { + render( + + ); + const titleElement = screen.getByRole("heading", { name: "countryName" }); + expect(titleElement).toBeInTheDocument(); +}); + +test("should render a link with the correct URL", () => { + render( + + ); + const linkElement = screen.getByRole("link", { name: "Manchester" }); + expect(linkElement).toBeInTheDocument(); + expect(linkElement).toHaveAttribute("href", "https://example.com"); +}); + +test("should render an image with alt text", () => { + render( + + ); + const imageElement = screen.getByAltText("Manchester"); + expect(imageElement).toBeInTheDocument(); +}); diff --git a/src/components/Deck/Deck.jsx b/src/components/Deck/Deck.jsx index c9215bc..aed596b 100644 --- a/src/components/Deck/Deck.jsx +++ b/src/components/Deck/Deck.jsx @@ -4,7 +4,7 @@ import cardsData from "@/data/fakeCards.json"; const Deck = (props) => { return ( -
+
{cardsData.map((city, index) => ( { + render(); + const cardcomponent = screen.getAllByTestId("info cards"); + const manchester = cardcomponent.filter((card) => + card.textContent.toLowerCase().includes("manchester") + ); + const glasgow = cardcomponent.filter((card) => + card.textContent.toLowerCase().includes("glasgow") + ); + const london = cardcomponent.filter((card) => + card.textContent.toLowerCase().includes("london") + ); + expect(manchester.length).toBeGreaterThan(0); + expect(glasgow.length).toBeGreaterThan(0); + expect(london.length).toBeGreaterThan(0); +}); +test("Each card should link to the correct website.", () => { + render(); + const cardcomponent = screen.getAllByTestId("info cards"); + cardcomponent.forEach((card) => { + const linkElement = card.querySelector("a"); + expect(linkElement).toBeInTheDocument(); + expect(linkElement).toHaveAttribute("href"); + }); +}); +test("Each card should link to the correct image.", () => { + render(); + const cardcomponent = screen.getAllByTestId("info cards"); + cardcomponent.forEach((card) => { + const imageElement = card.querySelector("img"); + expect(imageElement).toBeInTheDocument(); + expect(imageElement).toHaveAttribute("src"); + }); +}); diff --git a/src/components/SearchResult/__test__/featureactiverow.test.jsx b/src/components/SearchResult/__test__/featureactiverow.test.jsx new file mode 100644 index 0000000..ef29b6e --- /dev/null +++ b/src/components/SearchResult/__test__/featureactiverow.test.jsx @@ -0,0 +1,32 @@ +import TableBody from "../TableBody"; +import { render, screen, fireEvent } from "@testing-library/react"; + +test("Verify that each row of your table can be highlighted (on and off) independently when being clicked.", () => { + render( + + + + +
+ ); + + const tableRows = screen.getAllByRole("row"); + + tableRows.forEach((row) => { + fireEvent.click(row); + expect(row).toHaveClass("selected"); + fireEvent.click(row); + expect(row).not.toHaveClass("selected"); + }); +}); diff --git a/witch main b/witch main new file mode 100644 index 0000000..d39530a --- /dev/null +++ b/witch main @@ -0,0 +1,11 @@ + Feature-Active-row + Feature-Search-State + Feature-implement-Search-functionality + FeatureCalculateDuration + Search-onSubmit + feature-booking-state +* feature-card + feature-deck + fetch-bookings + main + search-results