Skip to content

Commit cb1c19e

Browse files
committed
test(utils): check username truncator boundary robustness (JhaSourav07#1563)
1 parent 4538996 commit cb1c19e

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

lib/svg/generator.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,4 +1264,24 @@ describe('Radar Scan Line Animation Alignment', () => {
12641264
// 5. Assert: Ensure the original string was actually modified
12651265
expect(result).not.toEqual(longUsername);
12661266
});
1267+
1268+
it('renders long usernames as truncated SVG labels without breaking geometry', () => {
1269+
const longUsername = 'ThisIsAVeryLongUsernameThatExceedsThirtyCharacters';
1270+
const svg = generateSVG(
1271+
{
1272+
currentStreak: 10,
1273+
longestStreak: 20,
1274+
totalContributions: 200,
1275+
todayDate: '2024-06-12',
1276+
},
1277+
{ user: longUsername, size: 'medium', autoTheme: false } as unknown as BadgeParams,
1278+
mockCalendar
1279+
);
1280+
1281+
expect(svg).toContain('...');
1282+
expect(svg).not.toContain(longUsername.toUpperCase());
1283+
expect(svg).toContain('text-anchor="middle"');
1284+
expect(svg).toContain('width="600"');
1285+
expect(svg).toContain('height="420"');
1286+
});
12671287
});

0 commit comments

Comments
 (0)