test: add defaultlayout tests
This commit is contained in:
parent
4e8c3ee6a6
commit
c2a308b36b
3 changed files with 31 additions and 2 deletions
|
@ -4,7 +4,7 @@ import style from './Footer.module.css'
|
|||
|
||||
function Footer () {
|
||||
return (
|
||||
<footer className={style.footer}>
|
||||
<footer className={style.footer} data-testid='footer'>
|
||||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
|
|
|
@ -5,7 +5,7 @@ import styles from './Header.module.css'
|
|||
|
||||
function Header () {
|
||||
return (
|
||||
<header className={styles.header}>
|
||||
<header className={styles.header} data-testid='header'>
|
||||
<nav>
|
||||
<Link href='/'>Home</Link>
|
||||
<Link href='/writing'>Writing</Link>
|
||||
|
|
29
src/layouts/DefaultLayout/DefaultLayout.test.jsx
Normal file
29
src/layouts/DefaultLayout/DefaultLayout.test.jsx
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* eslint-env jest */
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import DefaultLayout from './DefaultLayout'
|
||||
import '@testing-library/jest-dom'
|
||||
|
||||
describe('DefaultLayout', () => {
|
||||
const props = {
|
||||
children: <div>Test Content</div>
|
||||
}
|
||||
|
||||
it('renders without crashing', () => {
|
||||
render(<DefaultLayout {...props} />)
|
||||
})
|
||||
|
||||
it('renders Header', () => {
|
||||
render(<DefaultLayout {...props} />)
|
||||
expect(screen.getByTestId('header')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('renders Footer', () => {
|
||||
render(<DefaultLayout {...props} />)
|
||||
expect(screen.getByTestId('footer')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('renders children correctly', () => {
|
||||
render(<DefaultLayout {...props} />)
|
||||
expect(screen.getByText('Test Content')).toBeInTheDocument()
|
||||
})
|
||||
})
|
Loading…
Add table
Reference in a new issue