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);
    });
  });
});
