Files
landing-builder/components/i18n.form.actions.test.tsx

43 lines
2.2 KiB
TypeScript

import { render, screen } from '@testing-library/react'
import '@testing-library/jest-dom'
import React from 'react'
import BuilderClientPage from '@/components/BuilderClientPage'
import I18nProvider from '@/components/I18nProvider'
import en from '@/messages/en.json'
import ko from '@/messages/ko.json'
describe('i18n regression - form add actions (en/ko)', () => {
function renderWith(locale: 'en' | 'ko') {
const messages = locale === 'en' ? en : ko
return render(
<I18nProvider locale={locale} messages={messages as unknown as Record<string, string>}>
<BuilderClientPage />
</I18nProvider>
)
}
it('en labels exist for form field add buttons', () => {
renderWith('en')
expect(screen.getByRole('button', { name: 'Add Text' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Add Email' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Add Tel' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Add Date' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Add Textarea' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Add Checkbox' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Add Select' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Add Radio' })).toBeInTheDocument()
})
it('ko labels exist for form field add buttons', () => {
renderWith('ko')
expect(screen.getByRole('button', { name: '텍스트 필드 추가' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: '이메일 필드 추가' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: '전화번호 필드 추가' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: '날짜 필드 추가' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: '텍스트영역 추가' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: '체크박스 추가' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: '셀렉트 추가' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: '라디오 추가' })).toBeInTheDocument()
})
})