generated from Real-Dev-Squad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TEST: add test for Footer, Navbar and ProfileIcon
- Loading branch information
1 parent
90145d0
commit be6c16e
Showing
5 changed files
with
62 additions
and
2 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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
# testing | ||
/coverage | ||
/__tests__/__snapshots__ | ||
./__tests__/__snapshots__ | ||
|
||
# next.js | ||
/.next/ | ||
|
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,19 @@ | ||
import { Footer } from '@/components/Footer/Footer'; | ||
import { render } from '@testing-library/react'; | ||
|
||
describe('Footer', () => { | ||
it('should render', () => { | ||
const { container } = render(<Footer />); | ||
expect(container).toHaveTextContent('The contents of this website are deployed from this open sourced repo'); | ||
}); | ||
|
||
it('should have a link to the repo', () => { | ||
const { container } = render(<Footer />); | ||
expect(container.querySelector('a')).toHaveAttribute('href', '#'); | ||
}); | ||
|
||
it('should have a link to the repo', () => { | ||
const { container } = render(<Footer />); | ||
expect(container.querySelector('a')).toHaveAttribute('target', '_blank'); | ||
}); | ||
}); |
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,27 @@ | ||
import React from 'react'; | ||
import { Navbar } from '@/components/Navbar/Navbar'; | ||
import { render } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
|
||
describe('Navbar', () => { | ||
it('should render', () => { | ||
const { container } = render(<Navbar />); | ||
expect(container).toHaveTextContent('URL Shortener'); | ||
expect(container.querySelector('a')).toHaveAttribute('href', '#'); | ||
}); | ||
|
||
it('should have dropdown menu', () => { | ||
const { container } = render(<Navbar />); | ||
expect(container.querySelector('ul')).toHaveTextContent('Profile'); | ||
expect(container.querySelector('ul')).toHaveTextContent('Dashboard'); | ||
expect(container.querySelector('ul')).toHaveTextContent('Settings'); | ||
}); | ||
|
||
it('should toggle menu', () => { | ||
const { container } = render(<Navbar />); | ||
const button = container.querySelector('button'); | ||
expect(button).toHaveTextContent('Sunny'); | ||
button?.click(); | ||
expect(container.querySelector('ul')).toHaveClass('lg:flex space-x-4'); | ||
}); | ||
}); |
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,15 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import ProfileIcon from '@/components/ProfileIcon/ProfileIcon'; | ||
|
||
describe('ProfileIcon', () => { | ||
it('should render', () => { | ||
const { container } = render(<ProfileIcon firstName="Sunny" lastName="Sahsi" size={50} />); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('should have the correct initials', () => { | ||
const { container } = render(<ProfileIcon firstName="Sunny" lastName="Sahsi" size={50} />); | ||
expect(container).toHaveTextContent('SS'); | ||
}); | ||
}); |
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,4 +1,3 @@ | ||
// components/ProfileIcon.tsx | ||
import React from 'react'; | ||
|
||
interface ProfileIconProps { | ||
|