Skip to content

Commit 9155fd1

Browse files
test(svg): verify null deltaPercentage renders as N/A in generateMonthlySVG
1 parent e6b5723 commit 9155fd1

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

lib/svg/generator.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,41 @@ describe('generateMonthlySVG', () => {
10481048

10491049
expect(svg).toContain('COMMITS THIS MONTH');
10501050
});
1051+
1052+
it('renders monthly stats correctly with null deltaPercentage for delta_format percent', () => {
1053+
const nullDeltaStats: MonthlyStats = {
1054+
currentMonthTotal: 15,
1055+
previousMonthTotal: 0,
1056+
deltaPercentage: null,
1057+
deltaAbsolute: 15,
1058+
currentMonthName: 'June',
1059+
};
1060+
1061+
const svg = generateMonthlySVG(nullDeltaStats, {
1062+
user: 'octocat',
1063+
delta_format: 'percent',
1064+
} as unknown as BadgeParams);
1065+
1066+
expect(svg).toContain('N/A');
1067+
expect(svg).not.toContain('%');
1068+
});
1069+
1070+
it('renders monthly stats correctly with null deltaPercentage for delta_format both', () => {
1071+
const nullDeltaStats: MonthlyStats = {
1072+
currentMonthTotal: 15,
1073+
previousMonthTotal: 0,
1074+
deltaPercentage: null,
1075+
deltaAbsolute: 15,
1076+
currentMonthName: 'June',
1077+
};
1078+
1079+
const svg = generateMonthlySVG(nullDeltaStats, {
1080+
user: 'octocat',
1081+
delta_format: 'both',
1082+
} as unknown as BadgeParams);
1083+
1084+
expect(svg).toContain('N/A (+15)');
1085+
});
10511086
});
10521087

10531088
describe('shading and gradients', () => {

0 commit comments

Comments
 (0)