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>
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
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');
|
|
});
|
|
});
|