test(web): add Vitest+RTL tests for 15 design-system presentational components
Covers Badge, Divider, EmptyState, Numeric, PriceDelta, Signal, Skeleton, StatusChip, Surface, StatCard, KpiCard, DensityToggle, Footer, MarketIndex, CompactHeader — rendering, variants, props, a11y attributes, className merging. All 1139 web tests pass. Zustand persist store mocked for DensityToggle to avoid jsdom localStorage incompatibility. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
45
apps/web/components/design-system/__tests__/signal.spec.tsx
Normal file
45
apps/web/components/design-system/__tests__/signal.spec.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { Signal } from '../signal';
|
||||
|
||||
describe('Signal', () => {
|
||||
it('renders without a label', () => {
|
||||
const { container } = render(<Signal direction="up" />);
|
||||
expect(container.querySelector('span')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders label text when provided', () => {
|
||||
render(<Signal direction="up" label="Tăng" />);
|
||||
expect(screen.getByText('Tăng')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders icon with aria-hidden for up direction', () => {
|
||||
const { container } = render(<Signal direction="up" label="Up" />);
|
||||
expect(container.querySelector('[aria-hidden="true"]')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders icon with aria-hidden for down direction', () => {
|
||||
const { container } = render(<Signal direction="down" label="Down" />);
|
||||
expect(container.querySelector('[aria-hidden="true"]')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders icon with aria-hidden for neutral direction', () => {
|
||||
const { container } = render(<Signal direction="neutral" label="Neutral" />);
|
||||
expect(container.querySelector('[aria-hidden="true"]')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders as an inline span', () => {
|
||||
const { container } = render(<Signal direction="up" label="x" />);
|
||||
expect(container.firstChild?.nodeName).toBe('SPAN');
|
||||
});
|
||||
|
||||
it('merges custom className onto root span', () => {
|
||||
const { container } = render(<Signal direction="up" className="extra" label="x" />);
|
||||
expect(container.firstChild).toHaveClass('extra');
|
||||
});
|
||||
|
||||
it('contains an svg icon', () => {
|
||||
const { container } = render(<Signal direction="up" />);
|
||||
expect(container.querySelector('svg')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user