Skip to content

Commit 3c40bf6

Browse files
authored
test(svg): add accessibility coverage (JhaSourav07#3145)
## Description Fixes JhaSourav07#2886 Added isolated unit tests for `lib/svg/constants.ts` focusing on accessibility-related configuration stability and SVG rendering prerequisites. ### Changes - Added `lib/svg/constants.accessibility.test.ts` - Verified SVG dimension constants contain valid positive values - Tested font mapping definitions used for readable SVG text rendering - Confirmed contribution milestone values remain valid and positive - Verified streak milestone values remain valid and positive - Tested milestone collections maintain ascending ordering for predictable presentation and accessibility-friendly consumption - Improved coverage around accessibility-supporting SVG configuration data structures ## 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. - [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 starred 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 rendering changes made). - [ ] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 729912b + efa4f26 commit 3c40bf6

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// lib/svg/constants.accessibility.test.ts
2+
3+
import { describe, expect, it } from 'vitest';
4+
import {
5+
SVG_WIDTH,
6+
SVG_HEIGHT,
7+
FONT_MAP,
8+
CONTRIBUTION_MILESTONES,
9+
STREAK_MILESTONES,
10+
} from './constants';
11+
12+
describe('SVG Constants Accessibility', () => {
13+
it('provides valid SVG dimensions for accessible rendering', () => {
14+
expect(SVG_WIDTH).toBeGreaterThan(0);
15+
expect(SVG_HEIGHT).toBeGreaterThan(0);
16+
});
17+
18+
it('exposes readable font mappings for SVG text content', () => {
19+
expect(FONT_MAP).toHaveProperty('jetbrains');
20+
expect(FONT_MAP).toHaveProperty('fira');
21+
expect(FONT_MAP).toHaveProperty('roboto');
22+
23+
Object.values(FONT_MAP).forEach((font) => {
24+
expect(typeof font).toBe('string');
25+
expect(font.length).toBeGreaterThan(0);
26+
});
27+
});
28+
29+
it('defines contribution milestone values suitable for accessible labels', () => {
30+
expect(CONTRIBUTION_MILESTONES.length).toBeGreaterThan(0);
31+
32+
CONTRIBUTION_MILESTONES.forEach((value) => {
33+
expect(value).toBeGreaterThan(0);
34+
});
35+
});
36+
37+
it('defines streak milestone values suitable for accessible labels', () => {
38+
expect(STREAK_MILESTONES.length).toBeGreaterThan(0);
39+
40+
STREAK_MILESTONES.forEach((value) => {
41+
expect(value).toBeGreaterThan(0);
42+
});
43+
});
44+
45+
it('maintains ascending milestone ordering for predictable narration', () => {
46+
expect(CONTRIBUTION_MILESTONES).toEqual([...CONTRIBUTION_MILESTONES].sort((a, b) => a - b));
47+
48+
expect(STREAK_MILESTONES).toEqual([...STREAK_MILESTONES].sort((a, b) => a - b));
49+
});
50+
});

0 commit comments

Comments
 (0)