import { describe, it, expect, jest, beforeAll } from '@jest/globals'; import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom'; jest.mock('framer-motion', () => ({ motion: { div: ({ children, className, ...props }: any) => (
{children}
), section: ({ children, className, ...props }: any) => (
{children}
), span: ({ children, className, ...props }: any) => ( {children} ), h1: ({ children, className, ...props }: any) => (

{children}

), }, AnimatePresence: ({ children }: any) => <>{children}, })); jest.mock('next/link', () => { return ({ children, href, ...props }: any) => ( {children} ); }); jest.mock('lucide-react', () => ({ ArrowRight: () => , Shield: () => , Zap: () => , Award: () => , })); jest.mock('next/dynamic', () => { const React = require('react'); return { __esModule: true, default: (importFn: any, options: any) => { return React.forwardRef((props: any, ref: any) => { return null; }); }, }; }); jest.mock('@/components/ui/ripple-button', () => ({ RippleButton: ({ children, className, ...props }: any) => ( ), SealButton: ({ children, className, ...props }: any) => ( ), })); jest.mock('@/lib/animations', () => ({ GradientText: ({ children, className }: any) => ( {children} ), MagneticButton: ({ children, className }: any) => ( ), BlurReveal: ({ children, className }: any) => (
{children}
), CounterWithEffect: ({ end, suffix, className }: any) => ( {end}{suffix || ''} ), })); jest.mock('@/lib/constants', () => ({ COMPANY_INFO: { name: '四川睿新致远科技有限公司', shortName: '睿新致遠', description: '以智慧连接数字趋势,以伙伴身份陪您成长', }, STATS: [ { value: '10+', label: '企业客户' }, { value: '20+', label: '成功案例' }, { value: '30+', label: '项目交付' }, { value: '12+', label: '年行业经验' }, ], })); import { HeroSection } from './hero-section'; describe('HeroSection', () => { beforeAll(() => { jest.clearAllMocks(); }); describe('Rendering', () => { it('should render hero section', () => { render(); const section = document.querySelector('section#home'); expect(section).toBeInTheDocument(); }); it('should render company name', () => { render(); expect(screen.getByText('睿新致遠')).toBeInTheDocument(); }); it('should render features', () => { render(); expect(screen.getByText('安全可靠')).toBeInTheDocument(); expect(screen.getByText('高效便捷')).toBeInTheDocument(); expect(screen.getByText('专业服务')).toBeInTheDocument(); }); }); describe('Statistics', () => { it('should render statistics section', () => { render(); expect(screen.getByText('企业客户')).toBeInTheDocument(); expect(screen.getByText('成功案例')).toBeInTheDocument(); expect(screen.getByText('项目交付')).toBeInTheDocument(); expect(screen.getByText('年行业经验')).toBeInTheDocument(); }); }); describe('Accessibility', () => { it('should have proper ARIA labels', () => { render(); const section = document.querySelector('section#home'); expect(section).toHaveAttribute('aria-labelledby', 'hero-heading'); }); it('should have accessible buttons', () => { render(); const buttons = screen.getAllByRole('button'); expect(buttons.length).toBeGreaterThan(0); }); }); });