test: 修复因预发布模式文案变更导致的测试失败
- header/footer/mobile-menu/mobile-tab-bar: 更新导航项断言与 mock - insight-card/page-header: 适配组件结构变更(InkGlowCard、Badge) - about/products/news: 修复重复文本匹配,添加 PageNav/date-fns mock - constants: 更新服务标题断言 - 修复 mock 组件缺少 displayName 的 ESLint 错误
This commit is contained in:
@@ -10,6 +10,34 @@ jest.mock('next/image', () => ({
|
||||
),
|
||||
}));
|
||||
|
||||
jest.mock('@/components/ui/ink-glow-card', () => ({
|
||||
InkGlowCard: ({ children, className, href }: { children: React.ReactNode; className?: string; href?: string }) => (
|
||||
<article className={className} data-href={href}>
|
||||
{children}
|
||||
</article>
|
||||
),
|
||||
}));
|
||||
|
||||
jest.mock('@/components/ui/badge', () => ({
|
||||
Badge: ({ children, className }: { children: React.ReactNode; className?: string }) => (
|
||||
<span className={className}>{children}</span>
|
||||
),
|
||||
}));
|
||||
|
||||
jest.mock('lucide-react', () => ({
|
||||
Calendar: () => <span data-testid="calendar-icon" />,
|
||||
Clock: () => <span data-testid="clock-icon" />,
|
||||
ArrowRight: () => <span data-testid="arrow-right-icon" />,
|
||||
}));
|
||||
|
||||
jest.mock('next/link', () => {
|
||||
const MockLink = ({ children, href, ...props }: { children: React.ReactNode; href: string; [key: string]: unknown }) => (
|
||||
<a href={href} {...props}>{children}</a>
|
||||
);
|
||||
MockLink.displayName = 'MockLink';
|
||||
return MockLink;
|
||||
});
|
||||
|
||||
describe('InsightCard', () => {
|
||||
const defaultProps = {
|
||||
title: 'Test Title',
|
||||
@@ -96,16 +124,10 @@ describe('InsightCard', () => {
|
||||
expect(article).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should have border class', () => {
|
||||
const { container } = render(<InsightCard {...defaultProps} />);
|
||||
it('should pass featured class to InkGlowCard', () => {
|
||||
const { container } = render(<InsightCard {...defaultProps} featured />);
|
||||
const article = container.querySelector('article');
|
||||
expect(article).toHaveClass('border');
|
||||
});
|
||||
|
||||
it('should have rounded class', () => {
|
||||
const { container } = render(<InsightCard {...defaultProps} />);
|
||||
const article = container.querySelector('article');
|
||||
expect(article).toHaveClass('rounded-lg');
|
||||
expect(article).toHaveClass('md:col-span-2');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,16 +12,10 @@ jest.mock('framer-motion', () => ({
|
||||
useInView: () => true,
|
||||
}));
|
||||
|
||||
jest.mock('@/components/ui/ink-decoration', () => ({
|
||||
InkBackground: () => <div data-testid="ink-background" />,
|
||||
}));
|
||||
|
||||
jest.mock('@/components/effects/data-particle-flow', () => ({
|
||||
DataParticleFlow: () => <div data-testid="data-particle-flow" />,
|
||||
}));
|
||||
|
||||
jest.mock('@/components/effects/subtle-dots', () => ({
|
||||
SubtleDots: () => <div data-testid="subtle-dots" />,
|
||||
jest.mock('@/components/ui/badge', () => ({
|
||||
Badge: ({ children, className }: { children: React.ReactNode; className?: string }) => (
|
||||
<span className={className}>{children}</span>
|
||||
),
|
||||
}));
|
||||
|
||||
describe('PageHeader', () => {
|
||||
@@ -62,19 +56,16 @@ describe('PageHeader', () => {
|
||||
});
|
||||
|
||||
describe('Effects', () => {
|
||||
it('should render ink background', () => {
|
||||
render(<PageHeader title="Test" />);
|
||||
expect(screen.getByTestId('ink-background')).toBeInTheDocument();
|
||||
it('should have background styling', () => {
|
||||
const { container } = render(<PageHeader title="Test" />);
|
||||
const bgDiv = container.querySelector('.bg-\\[\\#FAFAFA\\]');
|
||||
expect(bgDiv).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render data particle flow', () => {
|
||||
render(<PageHeader title="Test" />);
|
||||
expect(screen.getByTestId('data-particle-flow')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render subtle dots', () => {
|
||||
render(<PageHeader title="Test" />);
|
||||
expect(screen.getByTestId('subtle-dots')).toBeInTheDocument();
|
||||
it('should have overflow hidden', () => {
|
||||
const { container } = render(<PageHeader title="Test" />);
|
||||
const wrapper = container.firstChild as HTMLElement;
|
||||
expect(wrapper).toHaveClass('overflow-hidden');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user