Skip to content

Commit 7e9e728

Browse files
test(layout): verify all towers have non-negative height values
1 parent a4dcf09 commit 7e9e728

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

lib/svg/layout.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,27 @@ describe('computeTowers edge cases', () => {
215215
// Assert intensityLevel is calculated correctly based on lines of code (60/60 = 100%, so intensity 4)
216216
expect(testTower.intensityLevel).toBe(4);
217217
});
218+
it('ensures all tower heights are non-negative', () => {
219+
const calendar = {
220+
totalContributions: 26,
221+
weeks: [
222+
{
223+
contributionDays: [
224+
{ contributionCount: 0, date: '2024-06-10' },
225+
{ contributionCount: 1, date: '2024-06-11' },
226+
{ contributionCount: 5, date: '2024-06-12' },
227+
{ contributionCount: 20, date: '2024-06-13' },
228+
],
229+
},
230+
],
231+
} as unknown as ContributionCalendar;
232+
233+
const towers = computeTowers(calendar, 'linear', '2024-06-13');
234+
235+
towers.forEach((tower) => {
236+
expect(tower.h).toBeGreaterThanOrEqual(0);
237+
});
238+
});
218239
});
219240

220241
it('assigns correct row and col values based on week/day position', () => {

0 commit comments

Comments
 (0)