Skip to content

Commit c261554

Browse files
authored
test: add LoC mode generator test (issue JhaSourav07#1081) (JhaSourav07#2224)
## Description Fixes JhaSourav07#1081 Added a generator test to verify that `generateSVG` correctly renders towers when `mode='loc'` and LoC data is present, even when the contribution count is zero. ### Changes Made * Created a test calendar with: * `contributionCount: 0` * `locAdditions: 50` * `locDeletions: 10` * Called `generateSVG` with `mode: 'loc'` * Added an assertion to verify that towers are rendered * Added an assertion to verify that the ghost city marker (`stroke-width="0.5"`) is not rendered ### Testing * Verified that all existing generator tests pass * Ran lint checks successfully (0 errors) ## 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) ## 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 lint` locally. * [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. * [ ] The SVG output matches the CommitPulse "premium quality" aesthetic standard. * [x] I joined the CommitPulse Discord community.
2 parents 8601213 + 0810fcc commit c261554

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

lib/svg/generator.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,38 @@ describe('generateSVG', () => {
373373
expect(svg).toContain('CURRENT_STREAK');
374374
});
375375

376+
describe('LoC Mode', () => {
377+
it('renders towers when LoC data exists (not ghost city)', () => {
378+
const locCalendar: ContributionCalendar = {
379+
totalContributions: 0,
380+
weeks: [
381+
{
382+
contributionDays: [
383+
{
384+
contributionCount: 0,
385+
locAdditions: 50,
386+
locDeletions: 10,
387+
date: '2024-06-10',
388+
},
389+
],
390+
},
391+
],
392+
} as ContributionCalendar;
393+
394+
const svg = generateSVG(
395+
mockStats,
396+
{ user: 'avi', mode: 'loc' } as unknown as BadgeParams,
397+
locCalendar
398+
);
399+
400+
// Should contain towers (LoC data exists, so it should not render the ghost city)
401+
expect(svg).toContain('class="cp-tower');
402+
403+
// Should NOT contain stroke-width="0.5" (the ghost city marker)
404+
expect(svg).not.toContain('stroke-width="0.5"');
405+
});
406+
});
407+
376408
// ── Auto-theme (prefers-color-scheme) tests ──────────────────────────────
377409
// These verify that theme=auto produces an SVG that switches between light
378410
// and dark color palettes using CSS custom properties and a media query,

0 commit comments

Comments
 (0)