import { describe, expect, it } from '@jest/globals'; import { render, screen as rtlScreen } from '@testing-library/react'; import { Legend } from '../../../atoms'; import { Switch, type SwitchOption } from './switch'; const doNothing = () => { /* Do nothing. */ }; const items: [SwitchOption, SwitchOption] = [ { id: 'item-1', label: 'Option 1', value: 'option-1' }, { id: 'item-2', label: 'Option 2', value: 'option-2' }, ]; describe('Switch', () => { it('renders a radio group with two choices', () => { const legend = 'Options:'; render( {legend}} name="possimus" onSwitch={doNothing} value={items[0].value} /> ); expect( rtlScreen.getByRole('radiogroup', { name: legend }) ).toBeInTheDocument(); expect(rtlScreen.getAllByRole('radio')).toHaveLength(items.length); }); it('can render a disabled switch', () => { render( ); const radios = rtlScreen.getAllByRole('radio'); expect(radios.every((radio) => radio.disabled)).toBe(true); expect(rtlScreen.getByRole('radiogroup')).toBeDisabled(); }); });