|
| 1 | +import { render, screen } from '@testing-library/react'; |
| 2 | +import '@testing-library/jest-dom/vitest'; |
| 3 | +import { describe, expect, it, vi } from 'vitest'; |
| 4 | +import { WallOfLove } from './WallOfLove'; |
| 5 | + |
| 6 | +// Mock framer-motion |
| 7 | +vi.mock('framer-motion', () => ({ |
| 8 | + motion: { |
| 9 | + p: (props: React.ComponentProps<'p'>) => <p {...props} />, |
| 10 | + }, |
| 11 | + useReducedMotion: () => true, |
| 12 | +})); |
| 13 | + |
| 14 | +// Mock gsap |
| 15 | +vi.mock('gsap', () => { |
| 16 | + const timeline = () => ({ |
| 17 | + to: vi.fn(), |
| 18 | + fromTo: vi.fn(), |
| 19 | + kill: vi.fn(), |
| 20 | + }); |
| 21 | + |
| 22 | + return { |
| 23 | + default: { |
| 24 | + registerPlugin: vi.fn(), |
| 25 | + context: (cb: () => void) => { |
| 26 | + cb(); |
| 27 | + return { revert: vi.fn() }; |
| 28 | + }, |
| 29 | + timeline, |
| 30 | + to: vi.fn(), |
| 31 | + set: vi.fn(), |
| 32 | + }, |
| 33 | + }; |
| 34 | +}); |
| 35 | + |
| 36 | +vi.mock('gsap/ScrollTrigger', () => ({ |
| 37 | + ScrollTrigger: {}, |
| 38 | +})); |
| 39 | + |
| 40 | +describe('WallOfLove', () => { |
| 41 | + it('renders section heading', () => { |
| 42 | + render(<WallOfLove />); |
| 43 | + |
| 44 | + const heading = screen.getByRole('heading', { |
| 45 | + level: 2, |
| 46 | + }); |
| 47 | + |
| 48 | + expect(heading).toHaveTextContent('Wall'); |
| 49 | + expect(heading).toHaveTextContent('Love'); |
| 50 | + }); |
| 51 | + |
| 52 | + it('renders testimonial author names', () => { |
| 53 | + render(<WallOfLove />); |
| 54 | + |
| 55 | + expect(screen.getAllByText('Alex Chen')[0]).toBeInTheDocument(); |
| 56 | + expect(screen.getAllByText('Priya Sharma')[0]).toBeInTheDocument(); |
| 57 | + expect(screen.getAllByText('David Kim')[0]).toBeInTheDocument(); |
| 58 | + }); |
| 59 | + |
| 60 | + it('renders testimonial handles', () => { |
| 61 | + render(<WallOfLove />); |
| 62 | + |
| 63 | + expect(screen.getAllByText('@alexcodes')[0]).toBeInTheDocument(); |
| 64 | + expect(screen.getAllByText('@priyabuilds')[0]).toBeInTheDocument(); |
| 65 | + expect(screen.getAllByText('@davidkim')[0]).toBeInTheDocument(); |
| 66 | + }); |
| 67 | + |
| 68 | + it('renders testimonial avatars', () => { |
| 69 | + render(<WallOfLove />); |
| 70 | + |
| 71 | + const avatars = screen.getAllByAltText('Alex Chen'); |
| 72 | + |
| 73 | + expect(avatars.length).toBeGreaterThan(0); |
| 74 | + expect(avatars[0]).toHaveAttribute('src'); |
| 75 | + }); |
| 76 | + |
| 77 | + it('renders stats section values', () => { |
| 78 | + render(<WallOfLove />); |
| 79 | + |
| 80 | + expect(screen.getByText('2K+')).toBeInTheDocument(); |
| 81 | + expect(screen.getByText('50K+')).toBeInTheDocument(); |
| 82 | + expect(screen.getByText('4.9')).toBeInTheDocument(); |
| 83 | + |
| 84 | + expect(screen.getByText('Happy Developers')).toBeInTheDocument(); |
| 85 | + expect(screen.getByText('Badges Generated')).toBeInTheDocument(); |
| 86 | + expect(screen.getByText('Average Rating')).toBeInTheDocument(); |
| 87 | + }); |
| 88 | +}); |
0 commit comments