Files
novalon-website/src/app/terms/page.test.tsx
T
张翔 b207bfa7af feat: 增加测试覆盖率并优化代码质量
test: 添加单元测试和端到端测试
refactor: 重构登录页面和上传模块
ci: 更新测试覆盖率阈值至42%
build: 添加测试相关依赖
docs: 更新测试文档
style: 修复代码格式问题
2026-03-11 11:14:37 +08:00

48 lines
1.5 KiB
TypeScript

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(<TermsOfServicePage />);
const container = screen.getByText('服务条款').closest('div');
expect(container).toBeInTheDocument();
});
it('should render page title', () => {
render(<TermsOfServicePage />);
const title = screen.getByRole('heading', { level: 1 });
expect(title).toBeInTheDocument();
expect(title).toHaveTextContent('服务条款');
});
it('should render introduction section', () => {
render(<TermsOfServicePage />);
const intro = screen.getByText('引言');
expect(intro).toBeInTheDocument();
});
it('should render service content section', () => {
render(<TermsOfServicePage />);
const sections = screen.getAllByRole('heading', { level: 2 });
expect(sections.length).toBeGreaterThan(0);
});
});
describe('Accessibility', () => {
it('should have proper heading hierarchy', () => {
render(<TermsOfServicePage />);
const h1 = screen.getByRole('heading', { level: 1 });
expect(h1).toBeInTheDocument();
const h2s = screen.getAllByRole('heading', { level: 2 });
expect(h2s.length).toBeGreaterThan(0);
});
});
});