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:
@@ -0,0 +1,40 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { EmptyState } from '../empty-state';
|
||||
|
||||
describe('EmptyState', () => {
|
||||
it('renders title', () => {
|
||||
render(<EmptyState title="Không có dữ liệu" />);
|
||||
expect(screen.getByText('Không có dữ liệu')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders description when provided', () => {
|
||||
render(<EmptyState title="Title" description="Mô tả phụ" />);
|
||||
expect(screen.getByText('Mô tả phụ')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not render description when omitted', () => {
|
||||
render(<EmptyState title="Title" />);
|
||||
expect(screen.queryByText('Mô tả phụ')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders icon node', () => {
|
||||
render(<EmptyState title="Title" icon={<span data-testid="icon" />} />);
|
||||
expect(screen.getByTestId('icon')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders action node', () => {
|
||||
render(
|
||||
<EmptyState
|
||||
title="Title"
|
||||
action={<button data-testid="action">Thêm mới</button>}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByTestId('action')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('merges custom className', () => {
|
||||
render(<EmptyState data-testid="es" title="T" className="custom" />);
|
||||
expect(screen.getByTestId('es')).toHaveClass('custom');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user