import { render, screen } from '@testing-library/react'; import { describe, expect, it } from 'vitest'; import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell } from '../table'; describe('Table', () => { it('renders a complete table structure', () => { render( Name Price Apartment 1,000,000 VND
, ); expect(screen.getByRole('table')).toBeInTheDocument(); expect(screen.getByText('Name')).toBeInTheDocument(); expect(screen.getByText('Price')).toBeInTheDocument(); expect(screen.getByText('Apartment')).toBeInTheDocument(); expect(screen.getByText('1,000,000 VND')).toBeInTheDocument(); }); it('renders multiple rows', () => { render( Row 1 Row 2 Row 3
, ); expect(screen.getAllByRole('row')).toHaveLength(3); }); it('applies custom className to table elements', () => { render( Data
, ); expect(screen.getByTestId('row')).toHaveClass('highlight'); expect(screen.getByTestId('cell')).toHaveClass('bold'); }); });