import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom'; import TermsOfServicePage from './page'; describe('TermsOfServicePage', () => { beforeEach(() => { jest.clearAllMocks(); }); describe('Rendering', () => { it('should render terms of service page', () => { render(); const container = screen.getByText('服务条款').closest('div'); expect(container).toBeInTheDocument(); }); it('should render page title', () => { render(); const title = screen.getByRole('heading', { level: 1 }); expect(title).toBeInTheDocument(); expect(title).toHaveTextContent('服务条款'); }); it('should render introduction section', () => { render(); const intro = screen.getByText('引言'); expect(intro).toBeInTheDocument(); }); it('should render service content section', () => { render(); const sections = screen.getAllByRole('heading', { level: 2 }); expect(sections.length).toBeGreaterThan(0); }); }); describe('Accessibility', () => { it('should have proper heading hierarchy', () => { render(); const h1 = screen.getByRole('heading', { level: 1 }); expect(h1).toBeInTheDocument(); const h2s = screen.getAllByRole('heading', { level: 2 }); expect(h2s.length).toBeGreaterThan(0); }); }); });