// @ts-nocheck
import { describe, it, expect, jest } from '@jest/globals';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import { MetricCard } from './metric-card';
// ─── Mocks ───────────────────────────────────────────────────────────────
jest.mock('framer-motion', () => ({
motion: {
div: ({ children, className, ...props }: any) => (
{children}
),
span: ({ children, className, ...props }: any) => (
{children}
),
},
useInView: jest.fn(() => true),
}));
jest.mock('lucide-react', () => ({
ArrowUpRight: (props: any) => ,
ArrowDownRight: (props: any) => ,
}));
jest.mock('@/components/ui/animated-counter', () => ({
AnimatedCounter: ({ value, prefix, suffix }: any) => (
{prefix}{value}{suffix}
),
}));
// ─── Tests ───────────────────────────────────────────────────────────────
describe('MetricCard', () => {
it('should render label and value', () => {
render();
expect(screen.getByText('客户数')).toBeInTheDocument();
expect(screen.getByText('500')).toBeInTheDocument();
});
it('should render icon when provided', () => {
render(
$}
/>
);
expect(screen.getByTestId('custom-icon')).toBeInTheDocument();
});
it('should render prefix and suffix', () => {
render();
expect(screen.getByText('+99%')).toBeInTheDocument();
});
it('should render description when provided', () => {
render();
expect(screen.getByText('活跃用户数')).toBeInTheDocument();
});
it('should render trend with up direction', () => {
render(
);
expect(screen.getByText('+12%')).toBeInTheDocument();
expect(screen.getByTestId('icon-trend-up')).toBeInTheDocument();
});
it('should render trend with down direction', () => {
render(
);
expect(screen.getByText('-2%')).toBeInTheDocument();
expect(screen.getByText('较上月')).toBeInTheDocument();
expect(screen.getByTestId('icon-trend-down')).toBeInTheDocument();
});
it('should apply custom className', () => {
const { container } = render(
);
const div = container.querySelector('.custom-class');
expect(div).toBeInTheDocument();
});
it('should render in dark theme', () => {
render();
expect(screen.getByText('Dark')).toBeInTheDocument();
});
it('should render with different accent colors', () => {
render();
expect(screen.getByText('Blue')).toBeInTheDocument();
});
});