import { render, screen } from '@testing-library/react'; import { describe, expect, it } from 'vitest'; import { Numeric } from '../numeric'; describe('Numeric', () => { it('formats VND by default', () => { render(); // Intl.NumberFormat vi-VN with currency VND — should contain digits expect(screen.getByText(/1\.000\.000/)).toBeInTheDocument(); }); it('formats percent', () => { render(); expect(screen.getByText('+5.5%')).toBeInTheDocument(); }); it('formats negative percent without plus sign', () => { render(); expect(screen.getByText('-3.2%')).toBeInTheDocument(); }); it('formats decimal', () => { render(); // vi-VN decimal uses comma as decimal separator expect(screen.getByText(/1\.234/)).toBeInTheDocument(); }); it('formats compact', () => { render(); expect(screen.getByText(/\d/)).toBeInTheDocument(); }); it('renders as span with data-numeric attribute', () => { render(); const el = screen.getByTestId('num'); expect(el.tagName).toBe('SPAN'); expect(el).toHaveAttribute('data-numeric'); }); it('has tabular-nums and font-mono classes', () => { render(); const el = screen.getByTestId('num'); expect(el).toHaveClass('tabular-nums', 'font-mono'); }); });