import { render, screen } from '@testing-library/react'; import { describe, expect, it } from 'vitest'; import { Button } from './Button'; describe('Button', () => { it('renders its children and defaults to type="button"', () => { render(); const button = screen.getByRole('button', { name: 'Click me' }); expect(button).toBeInTheDocument(); expect(button).toHaveAttribute('type', 'button'); }); it('shows a loading indicator when loading', () => { render(); expect(screen.getByRole('button', { name: /Save/ })).toBeDisabled(); expect(screen.getByRole('status', { name: 'Loading' })).toBeInTheDocument(); }); it('merges button styles onto a child element with asChild', () => { render( , ); const link = screen.getByRole('link', { name: 'Documentation' }); expect(link).toHaveAttribute('data-slot', 'button'); expect(link.className).toContain('border'); }); });