/** * Tests for the StatCard component * @jest-environment jsdom */ import React from 'react'; import { render, screen } from '@testing-library/react'; import { StatCard } from '@/components/ui/StatCard'; describe('StatCard', () => { it('should render with title and value', () => { render(); expect(screen.getByText('Total Tickets')).toBeInTheDocument(); expect(screen.getByText('150')).toBeInTheDocument(); }); it('should render string values', () => { render(); expect(screen.getByText('Status')).toBeInTheDocument(); expect(screen.getByText('Active')).toBeInTheDocument(); }); it('should render with icon', () => { const TestIcon = () => ; render(} />); expect(screen.getByTestId('test-icon')).toBeInTheDocument(); }); it('should render subtitle when provided', () => { render(); expect(screen.getByText('Last 30 days')).toBeInTheDocument(); }); it('should have white background for card', () => { const { container } = render(); const card = container.firstChild; expect(card).toHaveClass('bg-white'); }); it('should apply blue color to value text by default', () => { const { container } = render(); // The value text should have blue color const valueText = container.querySelector('.text-blue-600'); expect(valueText).toBeInTheDocument(); }); it('should apply green color to value text', () => { const { container } = render(); const valueText = container.querySelector('.text-green-600'); expect(valueText).toBeInTheDocument(); }); it('should apply yellow color to value text', () => { const { container } = render(); const valueText = container.querySelector('.text-yellow-600'); expect(valueText).toBeInTheDocument(); }); it('should apply red color to value text', () => { const { container } = render(); const valueText = container.querySelector('.text-red-600'); expect(valueText).toBeInTheDocument(); }); it('should apply purple color to value text', () => { const { container } = render(); const valueText = container.querySelector('.text-purple-600'); expect(valueText).toBeInTheDocument(); }); it('should apply custom className', () => { const { container } = render(); const card = container.firstChild; expect(card).toHaveClass('custom-class'); }); it('should render formatted numbers with French locale', () => { render(); // French locale uses non-breaking space as thousands separator // The exact format may vary, so we just check the number is present const valueElement = screen.getByText(/1.*000.*000/); expect(valueElement).toBeInTheDocument(); }); });