Skip to content

Commit bbdd929

Browse files
committed
test(generator): add coverage for exact SVG dimensions per size parameter
1 parent 9b64cab commit bbdd929

2 files changed

Lines changed: 36 additions & 6 deletions

File tree

app/api/streak/route.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
import { NextResponse } from 'next/server';
33
import { fetchGitHubContributions } from '../../../lib/github';
44
import { calculateStreak, calculateMonthlyStats } from '../../../lib/calculate';
5-
import {
6-
generateNotFoundSVG,
7-
generateSVG,
8-
generateMonthlySVG,
9-
escapeXML,
10-
} from '../../../lib/svg/generator';
5+
import { generateNotFoundSVG, generateSVG, generateMonthlySVG } from '../../../lib/svg/generator';
116
import { getSecondsUntilUTCMidnight, getSecondsUntilMidnightInTimezone } from '../../../utils/time';
127
import type { BadgeParams } from '../../../types';
138
import { themes } from '../../../lib/svg/themes';

lib/svg/generator.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,41 @@ describe('generateSVG', () => {
511511
expect(svg).not.toContain('fill="white" fill-opacity="0.2"');
512512
});
513513
});
514+
515+
describe('SVG dimensions per size', () => {
516+
it('renders width="600" and height="420" for medium size (default)', () => {
517+
const svg = generateSVG(
518+
mockStats,
519+
{ user: 'avi', size: 'medium' } as unknown as BadgeParams,
520+
mockCalendar
521+
);
522+
523+
expect(svg).toContain('width="600"');
524+
expect(svg).toContain('height="420"');
525+
});
526+
527+
it('renders width="400" and height="280" for small size', () => {
528+
const svg = generateSVG(
529+
mockStats,
530+
{ user: 'avi', size: 'small' } as unknown as BadgeParams,
531+
mockCalendar
532+
);
533+
534+
expect(svg).toContain('width="400"');
535+
expect(svg).toContain('height="280"');
536+
});
537+
538+
it('renders width="800" and height="560" for large size', () => {
539+
const svg = generateSVG(
540+
mockStats,
541+
{ user: 'avi', size: 'large' } as unknown as BadgeParams,
542+
mockCalendar
543+
);
544+
545+
expect(svg).toContain('width="800"');
546+
expect(svg).toContain('height="560"');
547+
});
548+
});
514549
});
515550

516551
describe('generateMonthlySVG', () => {

0 commit comments

Comments
 (0)