import { readFileSync } from 'node:fs'; import { join } from 'node:path'; import { render, screen } from '@testing-library/react'; import { describe, it, expect } from 'vitest'; import { SettingItem, ToggleSwitch, RadioGroup, Select } from '../settings-section'; describe('SettingItem controls', () => { it('names a toggle after the row label and reports its state', () => { render( {}} /> ); const toggle = screen.getByRole('switch', { name: 'Conversation view' }); expect(toggle).toHaveAttribute('aria-checked', 'true'); }); it('lets an explicit ariaLabel win over the row label', () => { render( {}} ariaLabel="Group by thread" /> ); expect(screen.getByRole('switch', { name: 'Group by thread' })).toHaveAttribute('aria-checked', 'false'); }); it('reports which option of a segmented control is active', () => { render( {}} options={[ { value: 'compact', label: 'Compact' }, { value: 'cosy', label: 'Cosy' }, ]} /> ); expect(screen.getByRole('button', { name: 'Cosy' })).toHaveAttribute('aria-pressed', 'true'); expect(screen.getByRole('button', { name: 'Compact' })).toHaveAttribute('aria-pressed', 'false'); expect(screen.getByRole('group', { name: 'Density' })).toBeTruthy(); }); it('names a select after the row label', () => { render(