Skip to content

Commit 7f2b56f

Browse files
committed
test: assert ghost city tower invariants
1 parent 7ee2274 commit 7f2b56f

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
@@ -100,6 +100,32 @@ describe('computeTowers edge cases', () => {
100100
expect(towers[0].strokeWidth).toBe(0.5);
101101
});
102102

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

0 commit comments

Comments
 (0)