Skip to content

Commit 8e8eb47

Browse files
authored
Test icons massive scaling (JhaSourav07#2997)
## Description Fixes JhaSourav07#2814 Added massive scaling test coverage for `app/components/Icons.tsx`. ### Tests Added * Verifies 500 CopyIcon instances render without crashing. * Verifies 500 ZapIcon instances render without crashing. * Confirms mixed icon sets render correctly under high volume. * Ensures CopyIcon dimension attributes remain stable across many renders. * Ensures CheckIcon stroke styling remains stable across high-volume renders. ## 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 (Test-only changes) ## Checklist before requesting a review: * [x] I have read the `CONTRIBUTING.md` file. * [x] I have tested these changes locally. * [ ] I have run `npm run format` and `npm run lint` locally and resolved all errors. * [x] My commits follow the Conventional Commits format. * [ ] I have updated `README.md` if I added a new theme or URL parameter. (Not applicable) * [x] I have starred 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. (Not applicable) * [ ] (Recommended) I joined the CommitPulse Discord community.
2 parents 146c36a + 8390273 commit 8e8eb47

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import type React from 'react';
2+
import { render, screen } from '@testing-library/react';
3+
import { describe, expect, it, vi } from 'vitest';
4+
5+
import { BoxIcon, CheckIcon, CloseIcon, CopyIcon, ZapIcon } from './Icons';
6+
7+
type IconProps = React.SVGProps<SVGSVGElement>;
8+
9+
vi.mock('lucide-react', () => ({
10+
Copy: (props: IconProps) => <svg data-testid="copy-icon" {...props} />,
11+
Zap: (props: IconProps) => <svg data-testid="zap-icon" {...props} />,
12+
Box: (props: IconProps) => <svg data-testid="box-icon" {...props} />,
13+
Check: (props: IconProps) => <svg data-testid="check-icon" {...props} />,
14+
X: (props: IconProps) => <svg data-testid="close-icon" {...props} />,
15+
}));
16+
17+
describe('Icons massive scaling behavior', () => {
18+
it('renders 500 CopyIcon instances without crashing', () => {
19+
render(
20+
<>
21+
{Array.from({ length: 500 }, (_, index) => (
22+
<CopyIcon key={index} />
23+
))}
24+
</>
25+
);
26+
27+
expect(screen.getAllByTestId('copy-icon')).toHaveLength(500);
28+
});
29+
30+
it('renders 500 ZapIcon instances without crashing', () => {
31+
render(
32+
<>
33+
{Array.from({ length: 500 }, (_, index) => (
34+
<ZapIcon key={index} />
35+
))}
36+
</>
37+
);
38+
39+
expect(screen.getAllByTestId('zap-icon')).toHaveLength(500);
40+
});
41+
42+
it('renders mixed icon sets at high volume', () => {
43+
render(
44+
<>
45+
{Array.from({ length: 100 }, (_, index) => (
46+
<div key={index}>
47+
<CopyIcon />
48+
<ZapIcon />
49+
<BoxIcon />
50+
<CheckIcon />
51+
<CloseIcon />
52+
</div>
53+
))}
54+
</>
55+
);
56+
57+
expect(screen.getAllByTestId('copy-icon')).toHaveLength(100);
58+
expect(screen.getAllByTestId('zap-icon')).toHaveLength(100);
59+
expect(screen.getAllByTestId('box-icon')).toHaveLength(100);
60+
expect(screen.getAllByTestId('check-icon')).toHaveLength(100);
61+
expect(screen.getAllByTestId('close-icon')).toHaveLength(100);
62+
});
63+
64+
it('preserves icon dimension attributes across many rendered icons', () => {
65+
render(
66+
<>
67+
{Array.from({ length: 100 }, (_, index) => (
68+
<CopyIcon key={index} />
69+
))}
70+
</>
71+
);
72+
73+
expect(
74+
screen.getAllByTestId('copy-icon').every((icon) => icon.getAttribute('width') === '20')
75+
).toBe(true);
76+
});
77+
78+
it('preserves CheckIcon stroke styling across high-volume renders', () => {
79+
render(
80+
<>
81+
{Array.from({ length: 100 }, (_, index) => (
82+
<CheckIcon key={index} />
83+
))}
84+
</>
85+
);
86+
87+
expect(
88+
screen.getAllByTestId('check-icon').every((icon) => icon.getAttribute('stroke') === '#10b981')
89+
).toBe(true);
90+
});
91+
});

0 commit comments

Comments
 (0)