Skip to content

Commit f0b129a

Browse files
test(svg): add scale=log integration test verifying different SVG output
1 parent e6b5723 commit f0b129a

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

app/api/streak/route.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,41 @@ describe('GET /api/streak', () => {
556556

557557
expect(response.status).toBe(200);
558558
});
559+
560+
it('produces different SVG output for scale=log versus scale=linear with mixed contribution counts', async () => {
561+
// Mix of low (1) and high (100) counts: linear scales them 1× vs 100×,
562+
// log compresses the ratio to log₂(2) vs log₂(101) — guaranteed to produce
563+
// different tower heights and therefore different path data in the SVG.
564+
vi.mocked(fetchGitHubContributions).mockResolvedValue({
565+
calendar: {
566+
totalContributions: 203,
567+
weeks: [
568+
{
569+
contributionDays: [
570+
{ contributionCount: 1, date: '2024-06-10' },
571+
{ contributionCount: 5, date: '2024-06-11' },
572+
{ contributionCount: 20, date: '2024-06-12' },
573+
{ contributionCount: 100, date: '2024-06-13' },
574+
{ contributionCount: 50, date: '2024-06-14' },
575+
{ contributionCount: 5, date: '2024-06-15' },
576+
{ contributionCount: 1, date: '2024-06-16' },
577+
],
578+
},
579+
],
580+
},
581+
repoContributions: [],
582+
} as unknown as ExtendedContributionData);
583+
584+
const linearResponse = await GET(makeRequest({ user: 'octocat', scale: 'linear' }));
585+
const logResponse = await GET(makeRequest({ user: 'octocat', scale: 'log' }));
586+
587+
const linearBody = await linearResponse.text();
588+
const logBody = await logResponse.text();
589+
590+
expect(linearResponse.status).toBe(200);
591+
expect(logResponse.status).toBe(200);
592+
expect(linearBody).not.toBe(logBody);
593+
});
559594
});
560595

561596
describe('year parameter', () => {

0 commit comments

Comments
 (0)