import { render, screen } from '@testing-library/react'; import { Checkbox } from './Checkbox'; import styles from './Checkbox.module.scss'; describe('checkbox tests', () => { it('renders checkbox', () => { render(); const checkbox = screen.getByLabelText('test label'); expect(checkbox).toBeInTheDocument(); }); it('renders switch', () => { render(); const checkbox = screen.getByRole('checkbox'); expect(checkbox).toHaveClass(styles.switch); }); it('applies className to label wrapper', () => { render(); const checkbox = screen.getByRole('checkbox'); const label = screen.getByText('test label'); expect(checkbox).not.toHaveClass('className'); expect(label).toHaveClass('className'); }); it('renders disabled checkbox', () => { render(); const checkbox = screen.getByRole('checkbox'); const label = screen.getByText('test label'); expect(checkbox).toBeDisabled(); expect(label).toHaveClass('disabled'); }); it('passes ref', () => { const ref = { current: null }; render(); const checkbox = screen.getByLabelText('test label'); expect(ref.current).toBe(checkbox); }); });