import { describe, it, expect, beforeEach, jest } from '@jest/globals';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import { TestimonialsSection } from './testimonials-section';
jest.mock('@/components/ui/testimonial-card', () => ({
TestimonialCard: ({ author, quote }: any) => (
),
}));
describe('TestimonialsSection', () => {
beforeEach(() => {
jest.clearAllMocks();
});
describe('Rendering', () => {
it('should render testimonials section', () => {
render();
const section = document.querySelector('section#testimonials');
expect(section).toBeInTheDocument();
});
it('should render section heading', () => {
render();
expect(screen.getByRole('heading', { level: 2 })).toBeInTheDocument();
});
it('should render section description', () => {
render();
expect(screen.getByText(/听听我们的客户怎么说/)).toBeInTheDocument();
});
it('should render testimonial cards', () => {
render();
const cards = screen.getAllByTestId('testimonial-card');
expect(cards.length).toBeGreaterThan(0);
});
it('should render testimonial authors', () => {
render();
expect(screen.getByText('张总')).toBeInTheDocument();
});
it('should render testimonial quotes', () => {
render();
expect(screen.getByText(/睿新致远的团队非常专业/)).toBeInTheDocument();
});
});
describe('Accessibility', () => {
it('should have section id', () => {
render();
const section = document.querySelector('section#testimonials');
expect(section).toBeInTheDocument();
});
});
describe('Styling', () => {
it('should have correct background', () => {
render();
const section = document.querySelector('section.bg-white');
expect(section).toBeInTheDocument();
});
it('should have container', () => {
render();
const container = document.querySelector('.container-wide');
expect(container).toBeInTheDocument();
});
it('should have grid layout', () => {
render();
const grid = document.querySelector('.grid');
expect(grid).toBeInTheDocument();
});
});
});