Skip to content

Commit 9510234

Browse files
authored
test(Icons): create app/components/Icons.test.tsx (JhaSourav07#3560)
## Description Creates `app/components/Icons.test.tsx` with 6 unit tests verifying each exported icon renders as a valid SVG with correct width, height, strokeWidth, and stroke color attributes. Fixes JhaSourav07#2285 ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview N/A ## 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): ...`). - [ ] 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. - [ ] 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 ca97bea + 2c8d57c commit 9510234

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

app/components/Icons.test.tsx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { render } from '@testing-library/react';
2+
import '@testing-library/jest-dom/vitest';
3+
import { describe, it, expect } from 'vitest';
4+
import { CopyIcon, ZapIcon, BoxIcon, CheckIcon, CloseIcon } from './Icons';
5+
6+
describe('Icons', () => {
7+
it('renders all 5 icons as valid SVG elements without crashing', () => {
8+
const icons = [CopyIcon, ZapIcon, BoxIcon, CheckIcon, CloseIcon];
9+
10+
icons.forEach((Icon) => {
11+
const { container } = render(<Icon />);
12+
const svg = container.querySelector('svg');
13+
expect(svg).toBeInTheDocument();
14+
});
15+
});
16+
17+
it('renders CopyIcon with correct attributes', () => {
18+
const { container } = render(<CopyIcon />);
19+
const svg = container.querySelector('svg');
20+
expect(svg).toBeInTheDocument();
21+
expect(svg).toHaveAttribute('width', '20');
22+
expect(svg).toHaveAttribute('height', '20');
23+
expect(svg).toHaveAttribute('stroke-width', '2');
24+
});
25+
26+
it('renders ZapIcon with correct attributes', () => {
27+
const { container } = render(<ZapIcon />);
28+
const svg = container.querySelector('svg');
29+
expect(svg).toBeInTheDocument();
30+
expect(svg).toHaveAttribute('width', '24');
31+
expect(svg).toHaveAttribute('height', '24');
32+
expect(svg).toHaveAttribute('stroke-width', '2');
33+
});
34+
35+
it('renders BoxIcon with correct attributes', () => {
36+
const { container } = render(<BoxIcon />);
37+
const svg = container.querySelector('svg');
38+
expect(svg).toBeInTheDocument();
39+
expect(svg).toHaveAttribute('width', '24');
40+
expect(svg).toHaveAttribute('height', '24');
41+
expect(svg).toHaveAttribute('stroke-width', '2');
42+
});
43+
44+
it('renders CheckIcon with correct attributes including green stroke color', () => {
45+
const { container } = render(<CheckIcon />);
46+
const svg = container.querySelector('svg');
47+
expect(svg).toBeInTheDocument();
48+
expect(svg).toHaveAttribute('width', '20');
49+
expect(svg).toHaveAttribute('height', '20');
50+
expect(svg).toHaveAttribute('stroke-width', '3');
51+
expect(svg).toHaveAttribute('stroke', '#10b981');
52+
});
53+
54+
it('renders CloseIcon with correct attributes', () => {
55+
const { container } = render(<CloseIcon />);
56+
const svg = container.querySelector('svg');
57+
expect(svg).toBeInTheDocument();
58+
expect(svg).toHaveAttribute('width', '18');
59+
expect(svg).toHaveAttribute('height', '18');
60+
expect(svg).toHaveAttribute('stroke-width', '2.5');
61+
});
62+
});

0 commit comments

Comments
 (0)