From a2a42a93dd67ae360379add9c889a0aa8f8b6936 Mon Sep 17 00:00:00 2001 From: AdrianTan166 Date: Sun, 19 May 2024 22:22:36 +1000 Subject: [PATCH] Fixed Tests --- src/components/atoms/Header/Header.test.tsx | 15 --------------- src/components/atoms/Header/Header.tsx | 13 ------------- .../organisms/ImagesList/HomeImageList.tsx | 4 ++-- src/components/pages/Home/Home.test.tsx | 6 ++++-- src/router/AppRouter.test.tsx | 6 ++++-- src/router/AppRouter.tsx | 2 -- 6 files changed, 10 insertions(+), 36 deletions(-) delete mode 100644 src/components/atoms/Header/Header.test.tsx delete mode 100644 src/components/atoms/Header/Header.tsx diff --git a/src/components/atoms/Header/Header.test.tsx b/src/components/atoms/Header/Header.test.tsx deleted file mode 100644 index 4544c45..0000000 --- a/src/components/atoms/Header/Header.test.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { render, screen } from "@testing-library/react"; -import Header from "./Header"; -import { MemoryRouter } from "react-router-dom"; - -describe("Header", () => { - it("should display", async () => { - render( - -
- - ); - const link = screen.getByRole("link"); - expect(link).toHaveTextContent("SpaceTitle"); - }); -}); diff --git a/src/components/atoms/Header/Header.tsx b/src/components/atoms/Header/Header.tsx deleted file mode 100644 index 42c5d1a..0000000 --- a/src/components/atoms/Header/Header.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { Link } from "react-router-dom"; - -const Header = () => { - return ( -
- -

- -
- ); -}; - -export default Header; diff --git a/src/components/organisms/ImagesList/HomeImageList.tsx b/src/components/organisms/ImagesList/HomeImageList.tsx index 3491748..4f547c7 100644 --- a/src/components/organisms/ImagesList/HomeImageList.tsx +++ b/src/components/organisms/ImagesList/HomeImageList.tsx @@ -22,12 +22,12 @@ const HomeImageList = () => { } // Render only the first row of images - const firstRowImages = data.pokemon_entries.slice(0, 6); // Assuming each row contains 4 images + const firstRowImages = data.slice(0, 6); // Assuming each row contains 4 images return (
{firstRowImages.map((image) => { - return ; + return ; })}
); diff --git a/src/components/pages/Home/Home.test.tsx b/src/components/pages/Home/Home.test.tsx index 4af010b..93b0b91 100644 --- a/src/components/pages/Home/Home.test.tsx +++ b/src/components/pages/Home/Home.test.tsx @@ -22,8 +22,10 @@ const wrapWithMemoryRouter = ( describe("Home", () => { it("should display the HTML content", async () => { renderWithQueryClientProvider(wrapWithMemoryRouter); - screen.getByText(/Welcome to Home Page/); - screen.getByText(/This is a paragraph/); + screen.getByText(/Send us your/); + screen.getByText(/Satellite Streak/); + screen.getByText(/Learn more/); + screen.getByText(/View Gallery/); // Add assertions for other elements if needed }); }); diff --git a/src/router/AppRouter.test.tsx b/src/router/AppRouter.test.tsx index bada054..66e6038 100644 --- a/src/router/AppRouter.test.tsx +++ b/src/router/AppRouter.test.tsx @@ -6,7 +6,9 @@ describe("AppRouter", () => { it("renders all components", async () => { renderWithQueryClientProvider(); - screen.getByText(/^SpaceTitle$/); - screen.getByText(/Placeholder Read Me/); + screen.getByText(/Send us your/); + screen.getByText(/Satellite Streak/); + screen.getByText(/Learn more/); + screen.getByText(/View Gallery/); }); }); diff --git a/src/router/AppRouter.tsx b/src/router/AppRouter.tsx index 31ede7c..cbe1d37 100644 --- a/src/router/AppRouter.tsx +++ b/src/router/AppRouter.tsx @@ -1,6 +1,5 @@ import { BrowserRouter, Route, Routes } from "react-router-dom"; import Gallery from "../components/pages/Gallery/Gallery"; -import Header from "src/components/atoms/Header/Header"; import Health from "src/components/molecules/Health/Health"; import Home from "src/components/pages/Home/Home"; import ImageInfo from "src/components/pages/ImageInfo/ImageInfo"; @@ -11,7 +10,6 @@ import Upload from "../components/pages/Upload/Upload"; const AppRouter = () => { return ( -