Skip to content

Commit 19446ce

Browse files
authored
test(generator): add coverage for tower top white highlight on count > 5 (JhaSourav07#429)
## Description Fixes JhaSourav07#404 - Added focused `test coverage` for the `tower-top white highlight rendering` in `generateSVG`, verifying it appears when `contributionCount > 5`. - Added a complementary `negative test` to ensure the highlight is not rendered when all contribution counts are ≤ 5, improving regression safety for SVG rendering behaviour. ## Pillar - 🛠️ Other (Bug fix, refactoring, docs) ## Checklist before requesting a review: - I have read the `CONTRIBUTING.md` file. - I have run `npm run format` and `npm run lint` locally and resolved all errors. - My commits follow the Conventional Commits format). - I have starred the repo. - I have made sure that i have only one commit to merge in this PR.
2 parents b42140a + 260413b commit 19446ce

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

lib/svg/generator.test.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,52 @@ describe('generateSVG', () => {
377377
expect(svg).not.toContain('attributeName="opacity" values="1;0.4;1"');
378378
});
379379
});
380+
381+
describe('tower top highlight', () => {
382+
it('renders white highlight on tower top when contributionCount > 5', () => {
383+
const calendarWithHighCount: ContributionCalendar = {
384+
totalContributions: 9,
385+
weeks: [
386+
{
387+
contributionDays: [
388+
{ contributionCount: 6, date: '2024-06-10' },
389+
{ contributionCount: 3, date: '2024-06-11' },
390+
],
391+
},
392+
],
393+
};
394+
395+
const svg = generateSVG(
396+
mockStats,
397+
{ user: 'avi' } as unknown as BadgeParams,
398+
calendarWithHighCount
399+
);
400+
401+
expect(svg).toContain('fill="white" fill-opacity="0.2"');
402+
});
403+
404+
it('does not render white highlight when all days have contributionCount <= 5', () => {
405+
const calendarWithLowCount: ContributionCalendar = {
406+
totalContributions: 8,
407+
weeks: [
408+
{
409+
contributionDays: [
410+
{ contributionCount: 3, date: '2024-06-10' },
411+
{ contributionCount: 5, date: '2024-06-11' },
412+
],
413+
},
414+
],
415+
};
416+
417+
const svg = generateSVG(
418+
mockStats,
419+
{ user: 'avi' } as unknown as BadgeParams,
420+
calendarWithLowCount
421+
);
422+
423+
expect(svg).not.toContain('fill="white" fill-opacity="0.2"');
424+
});
425+
});
380426
});
381427

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

0 commit comments

Comments
 (0)