import { render, screen } from '@testing-library/react' import { describe, it, expect } from 'vitest' import { axe } from 'vitest-axe' import { Field as BaseField } from '@base-ui/react/field' import { Fieldset, FieldsetLegend } from './fieldset' import { Field, FieldLabel } from '../field/field' describe('Fieldset', () => { it('renders a fieldset with an associated legend', () => { render(
Account Email
, ) const group = screen.getByRole('group', { name: 'Account' }) expect(group.tagName).toBe('FIELDSET') }) it('forwards className to the root and legend', () => { render(
Account
, ) const legend = screen.getByText('Account') expect(legend.className).toContain('legend-x') expect(screen.getByRole('group').className).toContain('root-x') }) it('disables descendant controls when disabled', () => { render(
Account Email
, ) expect(screen.getByLabelText('Email')).toBeDisabled() }) it('has no accessibility violations', async () => { const { container } = render(
Account Email
, ) expect(await axe(container)).toHaveNoViolations() }) })