diff --git a/src/app/(marketing)/about/page.test.tsx b/src/app/(marketing)/about/page.test.tsx index 4c53517..2d774b8 100644 --- a/src/app/(marketing)/about/page.test.tsx +++ b/src/app/(marketing)/about/page.test.tsx @@ -1,4 +1,4 @@ -import { describe, it, expect, jest, beforeAll } from '@jest/globals'; +import { describe, it, expect, jest } from '@jest/globals'; import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom'; @@ -35,11 +35,13 @@ jest.mock('framer-motion', () => ({ })); jest.mock('next/link', () => { - return ({ children, href, ...props }: any) => ( + const MockLink = ({ children, href, ...props }: any) => ( {children} ); + MockLink.displayName = 'MockLink'; + return MockLink; }); jest.mock('lucide-react', () => ({ diff --git a/src/app/(marketing)/products/[id]/page.test.tsx b/src/app/(marketing)/products/[id]/page.test.tsx index d42ecfc..14b093f 100644 --- a/src/app/(marketing)/products/[id]/page.test.tsx +++ b/src/app/(marketing)/products/[id]/page.test.tsx @@ -11,28 +11,13 @@ jest.mock('next/navigation', () => ({ })); jest.mock('next/link', () => { - return ({ children, href }: { children: React.ReactNode; href: string }) => { + const MockLink = ({ children, href }: { children: React.ReactNode; href: string }) => { return {children}; }; + MockLink.displayName = 'MockLink'; + return MockLink; }); -const mockProduct = { - id: 'test-product', - title: '测试产品', - category: '企业软件', - description: '这是测试产品描述', - overview: '这是测试产品概述', - features: ['功能1', '功能2'], - benefits: ['优势1', '优势2'], - process: ['步骤1', '步骤2'], - specs: ['规格1', '规格2'], - pricing: { - base: '¥10,000/年', - standard: '¥30,000/年', - enterprise: '定制', - }, -}; - jest.mock('@/lib/constants', () => ({ PRODUCTS: [ { diff --git a/src/components/ui/error-boundary.test.tsx b/src/components/ui/error-boundary.test.tsx index e81a073..982566b 100644 --- a/src/components/ui/error-boundary.test.tsx +++ b/src/components/ui/error-boundary.test.tsx @@ -1,5 +1,5 @@ import { describe, it, expect, beforeEach, jest } from '@jest/globals'; -import { render, screen, fireEvent } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom'; import { ErrorBoundary } from './error-boundary'; diff --git a/src/components/ui/input.test.tsx b/src/components/ui/input.test.tsx index 913b9ee..e4d62e1 100644 --- a/src/components/ui/input.test.tsx +++ b/src/components/ui/input.test.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { describe, it, expect, jest, beforeEach } from '@jest/globals'; -import { render, screen, fireEvent } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import '@testing-library/jest-dom'; import { Input } from './input'; diff --git a/src/components/ui/loading-skeleton.test.tsx b/src/components/ui/loading-skeleton.test.tsx index 53068f1..f1b84be 100644 --- a/src/components/ui/loading-skeleton.test.tsx +++ b/src/components/ui/loading-skeleton.test.tsx @@ -1,5 +1,5 @@ import { describe, it, expect } from '@jest/globals'; -import { render, screen } from '@testing-library/react'; +import { render } from '@testing-library/react'; import '@testing-library/jest-dom'; import { Skeleton, diff --git a/src/components/ui/ripple-button.test.tsx b/src/components/ui/ripple-button.test.tsx index ae7e346..3cee351 100644 --- a/src/components/ui/ripple-button.test.tsx +++ b/src/components/ui/ripple-button.test.tsx @@ -34,8 +34,6 @@ jest.mock('framer-motion', () => ({ AnimatePresence: ({ children }: { children: React.ReactNode }) => <>{children}, })); -const { RippleButton } = jest.requireActual('./ripple-button'); - describe('RippleButton', () => { beforeEach(() => { jest.clearAllMocks(); diff --git a/src/components/ui/sheet.test.tsx b/src/components/ui/sheet.test.tsx index 9ad5e46..5b404d1 100644 --- a/src/components/ui/sheet.test.tsx +++ b/src/components/ui/sheet.test.tsx @@ -9,7 +9,6 @@ import { SheetFooter, SheetTitle, SheetDescription, - SheetClose, } from './sheet'; describe('Sheet', () => { diff --git a/src/components/ui/textarea.test.tsx b/src/components/ui/textarea.test.tsx index 7df24ea..bcf4deb 100644 --- a/src/components/ui/textarea.test.tsx +++ b/src/components/ui/textarea.test.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { describe, it, expect, jest, beforeEach } from '@jest/globals'; -import { render, screen, fireEvent } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import '@testing-library/jest-dom'; import { Textarea } from './textarea'; diff --git a/src/hooks/use-focus-trap.test.ts b/src/hooks/use-focus-trap.test.ts index 1de8939..1c50a7a 100644 --- a/src/hooks/use-focus-trap.test.ts +++ b/src/hooks/use-focus-trap.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect, beforeEach, jest } from '@jest/globals'; -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; import { useFocusTrap } from './use-focus-trap'; describe('useFocusTrap', () => { diff --git a/src/lib/animations.test.tsx b/src/lib/animations.test.tsx index f18dce0..a33ffdd 100644 --- a/src/lib/animations.test.tsx +++ b/src/lib/animations.test.tsx @@ -77,7 +77,7 @@ describe('Animation Variants', () => { it('should have correct transition configuration', async () => { const { inkVariants } = await import('./animations'); - const transition = inkVariants.visible.transition as any; + const transition = (inkVariants.visible as any)?.transition; expect(transition.duration).toBe(0.8); expect(transition.ease).toEqual([0.16, 1, 0.3, 1]); }); @@ -102,7 +102,7 @@ describe('Animation Variants', () => { it('should use spring animation', async () => { const { sealStampVariants } = await import('./animations'); - const transition = sealStampVariants.visible.transition as any; + const transition = (sealStampVariants.visible as any)?.transition; expect(transition.type).toBe('spring'); expect(transition.stiffness).toBe(300); expect(transition.damping).toBe(20); @@ -144,7 +144,7 @@ describe('Animation Variants', () => { describe('staggerContainerVariants', () => { it('should have staggerChildren configured', async () => { const { staggerContainerVariants } = await import('./animations'); - const transition = staggerContainerVariants.visible.transition as any; + const transition = (staggerContainerVariants.visible as any)?.transition; expect(transition.staggerChildren).toBe(0.1); expect(transition.delayChildren).toBe(0.1); }); @@ -412,7 +412,7 @@ describe('Animation Components', () => { const { GlitchText } = await import('./animations'); render(); const testElements = screen.getAllByText('Test'); - const container = testElements[0].closest('.glitch-class'); + const container = testElements[0]?.closest('.glitch-class'); expect(container).toBeInTheDocument(); }); });