Skip to content

Commit 6eeb314

Browse files
authored
test: add unit tests for AchievementsSkeleton Component (JhaSourav07#1768)
## Description Fixes JhaSourav07#1013 ## Pillar - [ ] 🎨 Pillar 1 β€” New Theme Design - [ ] πŸ“ Pillar 2 β€” Geometric SVG Improvement - [ ] πŸ• Pillar 3 β€” Timezone Logic Optimization - [x] πŸ› οΈ Other (Bug fix, refactoring, docs) ## Visual Preview ## 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 df12e0e + b3e0a68 commit 6eeb314

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { render, screen } from '@testing-library/react';
2+
import { describe, it, expect } from 'vitest';
3+
4+
import AchievementsSkeleton from './AchievementsSkeleton';
5+
6+
describe('AchievementsSkeleton', () => {
7+
it(' renders without crashing', () => {
8+
expect(render(<AchievementsSkeleton />));
9+
});
10+
it(' renders exactly 4 skeleton cells.', () => {
11+
render(<AchievementsSkeleton />);
12+
const cells = screen.getAllByTestId('skeleton-cell');
13+
expect(cells).toHaveLength(4);
14+
});
15+
it('each cell has the shimmer class.', () => {
16+
render(<AchievementsSkeleton />);
17+
const cells = screen.getAllByTestId('skeleton-cell');
18+
19+
cells.forEach((cell) => {
20+
expect(cell.classList).toContain('shimmer');
21+
});
22+
});
23+
it('uses a grid-cols-2 layout.', () => {
24+
const { container } = render(<AchievementsSkeleton />);
25+
expect(container.querySelector('.grid-cols-2')).toBeTruthy();
26+
});
27+
});

β€Žcomponents/dashboard/AchievementsSkeleton.tsxβ€Ž

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ export default function AchievementsSkeleton() {
22
return (
33
<div className="grid grid-cols-2 gap-2">
44
{[...Array(4)].map((_, i) => (
5-
<div key={i} className="h-16 shimmer rounded border border-white/5" />
5+
<div
6+
key={i}
7+
className="h-16 shimmer rounded border border-white/5"
8+
data-testid="skeleton-cell"
9+
/>
610
))}
711
</div>
812
);

0 commit comments

Comments
Β (0)