import { describe, expect, it } from 'vitest' import { render, screen } from '@testing-library/react' import Pill, { pillColorList } from './Pill' describe('Pill', () => { it('renders with correct color', () => { render() const pill = screen.getByTestId('pill-component') expect(pill).toHaveAttribute('data-color', 'blue') }) it('renders with all available colors', () => { pillColorList.forEach((color) => { const { unmount } = render() const pill = screen.getByTestId('pill-component') expect(pill).toHaveAttribute('data-color', color) unmount() }) }) it('shows loading state', () => { render() expect(screen.getByTestId('pill-loading')).toBeInTheDocument() expect(screen.queryByTestId('pill-number')).not.toBeInTheDocument() }) it('shows number when not loading', () => { render() expect(screen.getByTestId('pill-number')).toBeInTheDocument() expect(screen.queryByTestId('pill-loading')).not.toBeInTheDocument() }) describe('number formatting', () => { it('formats small numbers', () => { render() expect(screen.getByTestId('pill-number')).toHaveTextContent('123') }) it('formats numbers with thousands separator', () => { render() expect(screen.getByTestId('pill-number')).toHaveTextContent('1,234') }) it('formats large numbers with suffix', () => { render() expect(screen.getByTestId('pill-number')).toHaveTextContent('1.23M') }) it('formats decimal numbers', () => { render() expect(screen.getByTestId('pill-number')).toHaveTextContent('1,234.57') }) it('formats negative numbers', () => { render() expect(screen.getByTestId('pill-number')).toHaveTextContent('-1,234') }) }) })