import React from 'react'; import { describe, it, expect, vi } from 'vitest'; import { render, fireEvent, screen } from '@testing-library/react'; import { PixelChip } from '../../data/PixelChip'; /* Extracted from __tests__/data/PixelBadgeChipUpgrade.test.tsx (additive upgrade: variant, size, iconLeft, onClick, deletable, onDelete) into the mirrored per-component file. */ describe('PixelChip — legacy behavior preserved', () => { it('renders label inside a ', () => { const { container } = render(); const root = container.firstElementChild as HTMLElement; expect(root.tagName).toBe('SPAN'); expect(root.textContent).toContain('React'); }); it('renders the remove X when onRemove is provided (legacy alias)', () => { const onRemove = vi.fn(); render(); const btn = screen.getByRole('button', { name: 'Remove React' }); expect(btn).toBeInTheDocument(); fireEvent.click(btn); expect(onRemove).toHaveBeenCalledTimes(1); }); it('default tone="cyan"', () => { const { container } = render(); const root = container.firstElementChild as HTMLElement; expect(root.className).toContain('text-retro-cyan'); }); }); describe('PixelChip — variant', () => { it('default variant is soft', () => { const { container } = render(); const root = container.firstElementChild as HTMLElement; expect(root.className).toContain('bg-retro-cyan/8'); }); it('variant="solid" uses opaque tone bg + contrasting text', () => { const { container } = render( , ); const root = container.firstElementChild as HTMLElement; // Regression: solid was painting the 18% tint (bg-retro-cyan/18) which // collapsed contrast. It now paints the opaque tone fill. const tokens = root.className.split(/\s+/); expect(tokens).toContain('bg-retro-cyan'); expect(tokens).not.toContain('bg-retro-cyan/18'); expect(root.className).toContain('text-retro-bg'); }); it('variant="outline" is transparent + tone border + tone text', () => { const { container } = render( , ); const root = container.firstElementChild as HTMLElement; expect(root.className).toContain('bg-transparent'); expect(root.className).toContain('border-retro-gold'); expect(root.className).toContain('text-retro-gold'); }); it('variant="ghost" drops border + tone text only', () => { const { container } = render( , ); const root = container.firstElementChild as HTMLElement; expect(root.className).toContain('bg-transparent'); expect(root.className).toContain('border-transparent'); expect(root.className).toContain('text-retro-pink'); }); }); describe('PixelChip — size', () => { it('default size="md"', () => { const { container } = render(); const root = container.firstElementChild as HTMLElement; expect(root.className).toContain('px-2.5'); expect(root.className).toContain('py-1'); expect(root.className).toContain('text-xs'); }); it('size="sm" applies tighter padding', () => { const { container } = render(); const root = container.firstElementChild as HTMLElement; expect(root.className).toContain('px-2'); expect(root.className).toContain('py-0.5'); expect(root.className).toContain('text-[11px]'); }); it('size="lg" applies bigger padding + larger text', () => { const { container } = render(); const root = container.firstElementChild as HTMLElement; expect(root.className).toContain('px-3'); expect(root.className).toContain('py-1.5'); expect(root.className).toContain('text-sm'); }); }); describe('PixelChip — iconLeft', () => { it('renders iconLeft node before label', () => { render( } />, ); expect(screen.getByTestId('ico')).toBeInTheDocument(); expect(screen.getByText('React')).toBeInTheDocument(); }); }); describe('PixelChip — onClick makes it a button', () => { it('renders