Skip to content

Commit 6c9f6dd

Browse files
authored
test(WallOfLove): add comprehensive component test coverage (JhaSourav07#3072)
## Description Adds comprehensive test coverage for the `WallOfLove` component by creating `components/WallOfLove.test.tsx`. ## 🎯 What was added - Verify the Wall of Love section heading renders correctly. - Verify testimonial author names are rendered. - Verify testimonial handles are rendered. - Verify testimonial avatars are rendered with valid image sources. - Verify stats section values and labels are displayed. Fixes JhaSourav07#2282 ## Pillar - [x] 🎨 Pillar 1 — New Theme Design - [x] 📐 Pillar 2 — Geometric SVG Improvement - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [x] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have started the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [x] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 27dd627 + c582357 commit 6c9f6dd

1 file changed

Lines changed: 88 additions & 0 deletions

File tree

components/WallOfLove.test.tsx

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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

Comments
 (0)