Skip to content

Commit 0c75cf1

Browse files
authored
test: assert ghost city tower invariants (JhaSourav07#820)
## Description Adds a test to verify ghost city invariants when contribution data contains only zero values. The test ensures: * every computed tower has `isGhost === true` * every tower height equals `4` (`GHOST_HEIGHT_PX`) This helps protect the expected ghost city rendering behavior from future regressions. Fixes JhaSourav07#728 --- ## 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 (`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. * [x] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). * [ ] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents e902357 + 7f2b56f commit 0c75cf1

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

lib/svg/layout.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,32 @@ describe('computeTowers edge cases', () => {
103103
expect(towers[0].strokeWidth).toBe(0.5);
104104
});
105105

106+
it('marks every tower as a ghost with ghost height for an all-zero calendar', () => {
107+
const calendar = {
108+
totalContributions: 0,
109+
weeks: [
110+
{
111+
contributionDays: [
112+
{ contributionCount: 0, date: '2024-06-10' },
113+
{ contributionCount: 0, date: '2024-06-11' },
114+
],
115+
},
116+
{
117+
contributionDays: [
118+
{ contributionCount: 0, date: '2024-06-12' },
119+
{ contributionCount: 0, date: '2024-06-13' },
120+
],
121+
},
122+
],
123+
} as unknown as ContributionCalendar;
124+
const towers = computeTowers(calendar, 'linear', '2024-06-13');
125+
126+
towers.forEach((tower) => {
127+
expect(tower.isGhost).toBe(true);
128+
expect(tower.h).toBe(4); // GHOST_HEIGHT_PX
129+
});
130+
});
131+
106132
it('disables ghost city mode when total visible contributions > 0', () => {
107133
const calendar = {
108134
totalContributions: 0,

0 commit comments

Comments
 (0)