test/user-journey #3

Merged
zhangxiang merged 142 commits from test/user-journey into dev 2026-04-12 13:17:03 +08:00
3 changed files with 38 additions and 11 deletions
Showing only changes of commit 87342cb208 - Show all commits
@@ -2,23 +2,31 @@ import { describe, it, expect, beforeEach, afterEach, jest } from '@jest/globals
import { render, screen, waitFor } from '@testing-library/react';
import '@testing-library/jest-dom';
import { NewsSection } from './news-section';
import type { ReactNode } from 'react';
jest.mock('framer-motion', () => ({
motion: {
div: ({ children, ...props }: any) => <div {...props}>{children}</div>,
div: ({ children, ...props }: { children?: ReactNode; [key: string]: unknown }) => <div {...props}>{children}</div>,
},
useInView: () => true,
}));
jest.mock('next/link', () => {
return ({ children, href }: any) => <a href={href}>{children}</a>;
const MockLink = ({ children, href }: { children?: ReactNode; href: string }) => <a href={href}>{children}</a>;
MockLink.displayName = 'MockLink';
return MockLink;
});
jest.mock('lucide-react', () => ({
ArrowRight: () => <span>ArrowRight</span>,
Calendar: () => <span>Calendar</span>,
}));
jest.mock('@/hooks/use-news', () => ({
useNews: jest.fn(),
}));
const { useNews } = require('@/hooks/use-news');
import { useNews } from '@/hooks/use-news';
describe('NewsSection Integration', () => {
beforeEach(() => {
@@ -2,23 +2,32 @@ import { describe, it, expect, beforeEach, afterEach, jest } from '@jest/globals
import { render, screen, waitFor } from '@testing-library/react';
import '@testing-library/jest-dom';
import { ProductsSection } from './products-section';
import type { ReactNode } from 'react';
jest.mock('framer-motion', () => ({
motion: {
div: ({ children, ...props }: any) => <div {...props}>{children}</div>,
div: ({ children, ...props }: { children?: ReactNode; [key: string]: unknown }) => <div {...props}>{children}</div>,
},
useInView: () => true,
}));
jest.mock('next/link', () => {
return ({ children, href }: any) => <a href={href}>{children}</a>;
const MockLink = ({ children, href }: { children?: ReactNode; href: string }) => <a href={href}>{children}</a>;
MockLink.displayName = 'MockLink';
return MockLink;
});
jest.mock('lucide-react', () => ({
ArrowRight: () => <span>ArrowRight</span>,
Check: () => <span>Check</span>,
TrendingUp: () => <span>TrendingUp</span>,
}));
jest.mock('@/hooks/use-products', () => ({
useProducts: jest.fn(),
}));
const { useProducts } = require('@/hooks/use-products');
import { useProducts } from '@/hooks/use-products';
describe('ProductsSection Integration', () => {
beforeEach(() => {
@@ -2,23 +2,34 @@ import { describe, it, expect, beforeEach, afterEach, jest } from '@jest/globals
import { render, screen, waitFor } from '@testing-library/react';
import '@testing-library/jest-dom';
import { ServicesSection } from './services-section';
import type { ReactNode } from 'react';
jest.mock('framer-motion', () => ({
motion: {
div: ({ children, ...props }: any) => <div {...props}>{children}</div>,
div: ({ children, ...props }: { children?: ReactNode; [key: string]: unknown }) => <div {...props}>{children}</div>,
},
useInView: () => true,
}));
jest.mock('next/link', () => {
return ({ children, href }: any) => <a href={href}>{children}</a>;
const MockLink = ({ children, href }: { children?: ReactNode; href: string }) => <a href={href}>{children}</a>;
MockLink.displayName = 'MockLink';
return MockLink;
});
jest.mock('lucide-react', () => ({
Code: () => <span>Code</span>,
Cloud: () => <span>Cloud</span>,
BarChart3: () => <span>BarChart3</span>,
Shield: () => <span>Shield</span>,
ArrowRight: () => <span>ArrowRight</span>,
}));
jest.mock('@/hooks/use-services', () => ({
useServices: jest.fn(),
}));
const { useServices } = require('@/hooks/use-services');
import { useServices } from '@/hooks/use-services';
describe('ServicesSection Integration', () => {
beforeEach(() => {
@@ -188,8 +199,7 @@ describe('ServicesSection Integration', () => {
render(<ServicesSection />);
await waitFor(() => {
const icons = document.querySelectorAll('svg');
expect(icons.length).toBeGreaterThan(0);
expect(screen.getByText('Code')).toBeInTheDocument();
});
});
});