import { describe, it, expect } from 'vitest' import { render, screen } from '@testing-library/react' import { CategoryLegend } from './category-legend' const noColors = () => undefined describe('', () => { it('renders nothing when series is empty', () => { const { container } = render( , ) expect(container.firstChild).toBeNull() }) it('renders one item per series with its name', () => { render( (i === 0 ? 'rgb(1, 1, 1)' : 'rgb(2, 2, 2)')} />, ) expect(screen.getByText('2024')).toBeTruthy() expect(screen.getByText('2025')).toBeTruthy() }) it('per-series color override (series[i].color) wins over colorAt(i)', () => { const { container } = render( 'rgb(0, 0, 0)'} />, ) const dot = Array.from(container.querySelectorAll('div')).find( (d) => (d as HTMLElement).style.backgroundColor === 'rgb(99, 0, 0)', ) expect(dot).toBeTruthy() }) it('falls back to colorAt(i) when series[i].color is absent', () => { const { container } = render( 'rgb(7, 7, 7)'} />, ) const dot = Array.from(container.querySelectorAll('div')).find( (d) => (d as HTMLElement).style.backgroundColor === 'rgb(7, 7, 7)', ) expect(dot).toBeTruthy() }) })