-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into mm-402-random-image
- Loading branch information
Showing
10 changed files
with
121 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,10 @@ | ||
import React from 'react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { render, screen } from '@testing-library/react'; | ||
import App from './App'; | ||
import "@testing-library/jest-dom"; | ||
import Hamburger from './Hamburgerbutton/Hamburgerbutton'; | ||
|
||
// remove this test when real tests are added | ||
test('renders header', () => { | ||
render(<App />); | ||
const header = screen.getAllByText(/MarsioKart/i); | ||
expect(header[0]).toBeInTheDocument(); | ||
}); | ||
|
||
test('calls onClick when Hamburger button is clicked', () => { | ||
const handleClick = jest.fn(); | ||
render(<Hamburger onClick={handleClick} label="Click Me" />); | ||
|
||
const button = screen.getByText('Click Me'); | ||
fireEvent.click(button); | ||
|
||
expect(handleClick).toHaveBeenCalledTimes(1); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import "@testing-library/jest-dom"; | ||
import Hamburger from '../Hamburgerbutton/Hamburgerbutton'; | ||
|
||
test('should toggle hamburger menu on button click', () => { | ||
render(<Hamburger />); | ||
|
||
const button = screen.getByTestId('toggle-button'); | ||
const menu = screen.queryByTestId('data-testid'); | ||
|
||
// Initially, the menu should not be visible | ||
expect(menu).not.toBeInTheDocument(); | ||
|
||
// Click the button to open the menu | ||
fireEvent.click(button); | ||
expect(screen.getByTestId('menu')).toBeInTheDocument(); | ||
|
||
// Click the button again to close the menu | ||
fireEvent.click(button); | ||
expect(screen.queryByTestId('menu')).not.toBeInTheDocument(); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
|
||
interface MenuItem { | ||
label: string; | ||
link: string; | ||
} | ||
|
||
interface MenuProps { | ||
items: MenuItem[]; | ||
} | ||
|
||
const Menu: React.FC<MenuProps> = ({ items }) => { | ||
return ( | ||
<div> | ||
<h1>Menu </h1> | ||
<nav> | ||
<ul> | ||
{items.map((item, index) => ( | ||
<li key={index}> | ||
<a href={item.link}>{item.label}</a> | ||
</li> | ||
))} | ||
</ul> | ||
</nav> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Menu; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
// list of the menu options that will be displayed when clicking on hamburger button | ||
export const menuItems = [ | ||
{ label: 'Home', link: '/' }, | ||
{ label: 'Quiz', link: '' }, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
import { QuestionDisplay } from "../QuestionDisplay/QuestionDisplay" | ||
|
||
export function Quiz () { | ||
interface getUserProp{ | ||
username:string; | ||
} | ||
|
||
export function Quiz (props:getUserProp) { | ||
return ( | ||
<QuestionDisplay/> | ||
<div> | ||
User : {props.username} | ||
<QuestionDisplay/> | ||
</div> | ||
) | ||
} |