test: add defaultlayout tests

This commit is contained in:
Aaron Yarborough 2024-03-22 17:17:55 +00:00
parent 4e8c3ee6a6
commit c2a308b36b
3 changed files with 31 additions and 2 deletions

View file

@ -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>

View file

@ -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>

View 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()
})
})