-
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.
MM-005: Add test for hamburger button
- Loading branch information
Showing
2 changed files
with
21 additions
and
4 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,9 +1,23 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import App from './App'; | ||
import Hamburger from './Hamburgerbutton'; | ||
|
||
test('renders learn react link', () => { | ||
/* test('renders learn react link', () => { | ||
render(<App />); | ||
const linkElement = screen.getByText(/learn react/i); | ||
expect(linkElement).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