Skip to content

Commit e8bcf90

Browse files
test(svg): verify all supported themes produce valid SVG output
1 parent 211cbb5 commit e8bcf90

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

lib/svg/generator.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from './generator';
1414
import type { BadgeParams, ContributionCalendar, StreakStats, MonthlyStats } from '../../types';
1515
import { hexColor } from './sanitizer';
16+
import { themes } from './themes';
1617

1718
describe('generateSVG', () => {
1819
const mockStats: StreakStats = {
@@ -867,6 +868,29 @@ describe('generateSVG', () => {
867868
expect(svg).not.toContain('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
868869
});
869870
});
871+
872+
describe('verify all supported themes produce valid SVG output', () => {
873+
it('generates a valid SVG and contains the theme accent color for each supported theme', () => {
874+
for (const theme of Object.values(themes)) {
875+
const svg = generateSVG(
876+
mockStats,
877+
{
878+
user: 'octocat',
879+
bg: theme.bg,
880+
text: theme.text,
881+
accent: theme.accent,
882+
speed: '8s',
883+
scale: 'linear',
884+
} as unknown as BadgeParams,
885+
mockCalendar
886+
);
887+
888+
expect(svg).toContain('<svg');
889+
expect(svg).toContain('</svg>');
890+
expect(svg.toLowerCase()).toContain(theme.accent.toLowerCase());
891+
}
892+
});
893+
});
870894
});
871895

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

0 commit comments

Comments
 (0)