From 371c2ec1e4d4e7009b3c992de617c33e9b955865 Mon Sep 17 00:00:00 2001 From: anum1608 Date: Thu, 1 Aug 2024 15:55:56 +0100 Subject: [PATCH] mm-107-startquizbuttonv2: correction made as per PR review comments --- src/Home/Home.test.tsx | 20 -------------------- src/Home/Home.tsx | 9 ++------- src/Quiz/Quiz.tsx | 4 ++-- 3 files changed, 4 insertions(+), 29 deletions(-) delete mode 100644 src/Home/Home.test.tsx diff --git a/src/Home/Home.test.tsx b/src/Home/Home.test.tsx deleted file mode 100644 index 072609a..0000000 --- a/src/Home/Home.test.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { fireEvent, render, screen } from "@testing-library/react"; -import Home from "./Home"; -import "@testing-library/jest-dom"; -import React, { useState } from "react"; - -test.skip("user's name is displayed on form submission", () => { - const name = "Luigi"; - const [username, setUsername] = useState(name); - - render(); - - const textArea = screen.getByLabelText(/Enter name:/); - fireEvent.change(textArea, { target: { value: name }}); - - const submitButton = screen.getByRole("button"); - fireEvent.click(submitButton); - - const welcomeMessage = screen.getByText(/Welcome Luigi!/i); - expect(welcomeMessage).toBeInTheDocument(); -}) \ No newline at end of file diff --git a/src/Home/Home.tsx b/src/Home/Home.tsx index 14640c6..a85023a 100644 --- a/src/Home/Home.tsx +++ b/src/Home/Home.tsx @@ -2,14 +2,13 @@ import React, { useState } from "react"; import { useNavigate } from "react-router-dom"; import DisplayBackgroundImage from '../images/DisplayBackgroundImage'; -interface getUserProp{ +interface HomeProps{ username:string; setUsername:(uname:string)=>void; } -function Home(props:getUserProp) { +function Home(props:HomeProps) { - //const [username, setUsername] = useState(""); const [submitStatus, setSubmitStatus] = useState(false); const handleSubmit = (event: React.FormEvent) => { @@ -28,24 +27,20 @@ function Home(props:getUserProp) { return ( <>
- {/* Other components and content */}
{submitStatus ?

Welcome {props.username}!

: null}
- -
) diff --git a/src/Quiz/Quiz.tsx b/src/Quiz/Quiz.tsx index d54f1fd..1d01719 100644 --- a/src/Quiz/Quiz.tsx +++ b/src/Quiz/Quiz.tsx @@ -1,10 +1,10 @@ import { QuestionDisplay } from "../QuestionDisplay/QuestionDisplay" -interface getUserProp{ +interface QuizProps{ username:string; } -export function Quiz (props:getUserProp) { +export function Quiz (props:QuizProps) { return (
User : {props.username}