This commit is contained in:
2026-05-13 20:42:25 +09:00
parent add60cb413
commit 0a13c00f37
48 changed files with 2378 additions and 7 deletions
@@ -0,0 +1,39 @@
import { createRef } from 'react'
import { render, screen } from '@testing-library/react'
import { describe, expect, it } from 'vitest'
import Form from '@/components/common/Form'
import SectionTitle from '@/components/common/SectionTitle'
import SubsectionTitle from '@/components/common/SubsectionTitle'
import TextArea from '@/components/common/TextArea'
describe ('common typography and form components', () => {
it ('renders Form children inside the standard container', () => {
render (<Form><span>Content</span></Form>)
expect (screen.getByText ('Content').parentElement).toHaveClass ('max-w-xl')
})
it ('renders SectionTitle as an h2 and merges custom classes', () => {
render (<SectionTitle className="custom">Section</SectionTitle>)
const heading = screen.getByRole ('heading', { level: 2, name: 'Section' })
expect (heading).toHaveClass ('text-xl')
expect (heading).toHaveClass ('custom')
})
it ('renders SubsectionTitle as an h3', () => {
render (<SubsectionTitle>Subsection</SubsectionTitle>)
expect (screen.getByRole ('heading', { level: 3, name: 'Subsection' })).toBeInTheDocument ()
})
it ('forwards refs and props to TextArea', () => {
const ref = createRef<HTMLTextAreaElement> ()
render (<TextArea ref={ref} aria-label="Body" defaultValue="text"/>)
expect (ref.current).toBe (screen.getByLabelText ('Body'))
expect (screen.getByLabelText ('Body')).toHaveValue ('text')
})
})