import { render, screen } from '@testing-library/react'; import { describe, it, expect } from 'vitest'; import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell, } from './table'; describe('Table Component', () => { it('renders table with header and body', () => { render( Name Email John Doe john@example.com
, ); expect(screen.getByText('Name')).toBeInTheDocument(); expect(screen.getByText('Email')).toBeInTheDocument(); expect(screen.getByText('John Doe')).toBeInTheDocument(); expect(screen.getByText('john@example.com')).toBeInTheDocument(); }); it('renders multiple rows', () => { render( Name John Jane
, ); expect(screen.getByText('John')).toBeInTheDocument(); expect(screen.getByText('Jane')).toBeInTheDocument(); }); it('applies custom className to table', () => { render( Name John
, ); const table = screen.getByRole('table'); expect(table).toHaveClass('custom-table'); }); it('applies custom className to table row', () => { render( John
, ); const row = screen.getByText('John').closest('tr'); expect(row).toHaveClass('custom-row'); }); it('renders table head with correct styling', () => { render( Name
, ); const head = screen.getByText('Name'); expect(head.tagName).toBe('TH'); }); it('renders table cell with correct styling', () => { render( John
, ); const cell = screen.getByText('John'); expect(cell.tagName).toBe('TD'); }); });