Commit 1eae6cd
authored
test: validate generated SVG output with DOMParser (JhaSourav07#2236)
## Description
Fixes JhaSourav07#392
Added SVG validation coverage to 'lib/svg/generator.test.ts' by
introducing an 'assertValidSVG()' helper that parses generated SVG
output with 'DOMParser' and verifies that no parser errors are present.
### Changes made
1. Added 'assertValidSVG(svgString: string)' helper
2. Parses SVG output using 'DOMParser' with 'image/svg+xml'
3. Verifies generated SVGs are well-formed XML/SVG documents
4. Added validation checks to 5 existing SVG generation test cases
5. Preserved all existing test assertions
## 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 change, no visual SVG output was modified.
## 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=Harshitbhardwaj468').
* [x] I have run 'npm run format' and 'npm run lint' locally and
resolved all errors introduced by this change.
* [x] I have run 'npm run test' and all tests pass locally.
* [ ] I have run 'npm run test:coverage' and branch coverage is at or
above 70%.
* [x] My commits follow the Conventional Commits format.
* [ ] 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 production SVG output was modified).
* [x] (Recommended) I joined the CommitPulse Discord server for faster
collaboration, mentorship, and PR support.
### Verification
npm run test
Result:
No test failures introduced by this change1 file changed
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
19 | 27 | | |
20 | 28 | | |
21 | 29 | | |
| |||
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
| 61 | + | |
| 62 | + | |
53 | 63 | | |
54 | 64 | | |
55 | 65 | | |
| |||
70 | 80 | | |
71 | 81 | | |
72 | 82 | | |
| 83 | + | |
| 84 | + | |
73 | 85 | | |
74 | 86 | | |
75 | 87 | | |
| |||
78 | 90 | | |
79 | 91 | | |
80 | 92 | | |
| 93 | + | |
| 94 | + | |
81 | 95 | | |
82 | 96 | | |
83 | 97 | | |
| |||
89 | 103 | | |
90 | 104 | | |
91 | 105 | | |
| 106 | + | |
| 107 | + | |
92 | 108 | | |
93 | 109 | | |
94 | 110 | | |
| |||
99 | 115 | | |
100 | 116 | | |
101 | 117 | | |
| 118 | + | |
| 119 | + | |
102 | 120 | | |
103 | 121 | | |
104 | 122 | | |
| |||
0 commit comments