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:
41
apps/web/components/design-system/__tests__/divider.spec.tsx
Normal file
41
apps/web/components/design-system/__tests__/divider.spec.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { Divider } from '../divider';
|
||||
|
||||
describe('Divider', () => {
|
||||
it('renders with role="separator"', () => {
|
||||
render(<Divider />);
|
||||
expect(screen.getByRole('separator')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('defaults to horizontal orientation', () => {
|
||||
render(<Divider data-testid="d" />);
|
||||
expect(screen.getByTestId('d')).toHaveAttribute('aria-orientation', 'horizontal');
|
||||
});
|
||||
|
||||
it('renders vertical orientation', () => {
|
||||
render(<Divider data-testid="d" orientation="vertical" />);
|
||||
expect(screen.getByTestId('d')).toHaveAttribute('aria-orientation', 'vertical');
|
||||
expect(screen.getByTestId('d')).toHaveClass('h-full', 'w-px');
|
||||
});
|
||||
|
||||
it('applies strong variant class', () => {
|
||||
render(<Divider data-testid="d" strong />);
|
||||
expect(screen.getByTestId('d')).toHaveClass('bg-border-strong');
|
||||
});
|
||||
|
||||
it('applies default border class without strong', () => {
|
||||
render(<Divider data-testid="d" />);
|
||||
expect(screen.getByTestId('d')).toHaveClass('bg-border');
|
||||
});
|
||||
|
||||
it('horizontal adds h-px and w-full', () => {
|
||||
render(<Divider data-testid="d" orientation="horizontal" />);
|
||||
expect(screen.getByTestId('d')).toHaveClass('h-px', 'w-full');
|
||||
});
|
||||
|
||||
it('merges custom className', () => {
|
||||
render(<Divider data-testid="d" className="my-custom" />);
|
||||
expect(screen.getByTestId('d')).toHaveClass('my-custom');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user