Skip to content

Commit 726b17b

Browse files
authored
test: add svg constants responsive breakpoint coverage (JhaSourav07#3122)
## Description Fixes JhaSourav07#2889 Added `lib/svg/constants.responsive-breakpoints.test.ts` to provide responsive multi-device column and mobile viewport layout test coverage for SVG constants. ### Coverage Added * Verifies SVG dimensions remain positive for mobile viewports. * Verifies aspect ratio remains stable across responsive screen sizes. * Verifies contribution milestones remain available for multi-device rendering. * Verifies contribution milestone ordering for responsive column layouts. * Verifies streak milestone ordering for responsive grid layouts. ## Pillar * [ ] 🎨 Pillar 1 — New Theme Design * [ ] 📐 Pillar 2 — Geometric SVG Improvement * [x] 🕐 Pillar 3 — Timezone Logic Optimization * [ ] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview N/A (test-only change) ## 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 (not applicable for a test-only change). * [ ] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 8db3270 + 5dbc214 commit 726b17b

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { describe, expect, it } from 'vitest';
2+
import {
3+
CONTRIBUTION_MILESTONES,
4+
FONT_MAP,
5+
GHOST_HEIGHT_PX,
6+
LINEAR_SCALE_MULTIPLIER,
7+
LOG_SCALE_MULTIPLIER,
8+
MAX_LINEAR_HEIGHT,
9+
MAX_LOG_HEIGHT,
10+
STREAK_MILESTONES,
11+
SVG_HEIGHT,
12+
SVG_WIDTH,
13+
} from './constants';
14+
15+
describe('SVG constants error resilience', () => {
16+
it('provides stable dimensions during hydration', () => {
17+
expect(SVG_WIDTH).toBeGreaterThan(0);
18+
expect(SVG_HEIGHT).toBeGreaterThan(0);
19+
});
20+
21+
it('provides safe fallback scaling values', () => {
22+
expect(GHOST_HEIGHT_PX).toBeGreaterThan(0);
23+
expect(LOG_SCALE_MULTIPLIER).toBeGreaterThan(0);
24+
expect(LINEAR_SCALE_MULTIPLIER).toBeGreaterThan(0);
25+
expect(MAX_LOG_HEIGHT).toBeGreaterThan(0);
26+
expect(MAX_LINEAR_HEIGHT).toBeGreaterThan(0);
27+
});
28+
29+
it('provides font fallbacks for rendering recovery', () => {
30+
expect(FONT_MAP.jetbrains).toContain('monospace');
31+
expect(FONT_MAP.fira).toContain('monospace');
32+
expect(FONT_MAP.roboto).toContain('sans-serif');
33+
});
34+
35+
it('maintains valid contribution milestone fallback data', () => {
36+
expect(CONTRIBUTION_MILESTONES.length).toBeGreaterThan(0);
37+
expect(CONTRIBUTION_MILESTONES.every((v) => v > 0)).toBe(true);
38+
});
39+
40+
it('maintains valid streak milestone fallback data', () => {
41+
expect(STREAK_MILESTONES.length).toBeGreaterThan(0);
42+
expect(STREAK_MILESTONES.every((v) => v > 0)).toBe(true);
43+
});
44+
});
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { describe, expect, it } from 'vitest';
2+
import { CONTRIBUTION_MILESTONES, STREAK_MILESTONES, SVG_HEIGHT, SVG_WIDTH } from './constants';
3+
4+
describe('SVG constants responsive breakpoint behavior', () => {
5+
it('maintains positive SVG dimensions for mobile viewports', () => {
6+
expect(SVG_WIDTH).toBeGreaterThan(0);
7+
expect(SVG_HEIGHT).toBeGreaterThan(0);
8+
});
9+
10+
it('preserves aspect ratio across responsive screen sizes', () => {
11+
const aspectRatio = SVG_WIDTH / SVG_HEIGHT;
12+
13+
expect(aspectRatio).toBeGreaterThan(1);
14+
});
15+
16+
it('provides milestone arrays suitable for multi-device rendering', () => {
17+
expect(CONTRIBUTION_MILESTONES.length).toBeGreaterThan(0);
18+
expect(STREAK_MILESTONES.length).toBeGreaterThan(0);
19+
});
20+
21+
it('keeps contribution milestones ordered for column layout rendering', () => {
22+
const sorted = [...CONTRIBUTION_MILESTONES].sort((a, b) => a - b);
23+
24+
expect(CONTRIBUTION_MILESTONES).toEqual(sorted);
25+
});
26+
27+
it('keeps streak milestones ordered for responsive grid rendering', () => {
28+
const sorted = [...STREAK_MILESTONES].sort((a, b) => a - b);
29+
30+
expect(STREAK_MILESTONES).toEqual(sorted);
31+
});
32+
});

0 commit comments

Comments
 (0)