Skip to content

Commit fb49689

Browse files
committed
test(layout): verify row and col mapping
1 parent 9b64cab commit fb49689

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

lib/svg/layout.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,36 @@ describe('computeTowers edge cases', () => {
160160
expect(towers[0].h).toBe(24);
161161
});
162162
});
163+
164+
it('assigns correct row and col values based on week/day position', () => {
165+
const calendar = {
166+
totalContributions: 0,
167+
weeks: [
168+
{
169+
contributionDays: [
170+
{ contributionCount: 1, date: '2024-06-10' },
171+
{ contributionCount: 1, date: '2024-06-11' },
172+
{ contributionCount: 1, date: '2024-06-12' },
173+
],
174+
},
175+
{
176+
contributionDays: [
177+
{ contributionCount: 1, date: '2024-06-13' },
178+
{ contributionCount: 1, date: '2024-06-14' },
179+
{ contributionCount: 1, date: '2024-06-15' },
180+
],
181+
},
182+
],
183+
} as unknown as ContributionCalendar;
184+
185+
const towers = computeTowers(calendar, 'linear', '2024-06-15');
186+
187+
expect(towers[0].row).toBe(0);
188+
expect(towers[0].col).toBe(0);
189+
190+
expect(towers[1].row).toBe(0);
191+
expect(towers[1].col).toBe(1);
192+
193+
expect(towers[3].row).toBe(1);
194+
expect(towers[3].col).toBe(0);
195+
});

0 commit comments

Comments
 (0)