test(persons): expand CoCorrespondentsList coverage

Adds single-word name (one-initial) and leading-space edge cases
for the initials function.

2 new tests covering ~4 branches.

Refs #496.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-10 06:12:19 +02:00
parent 1229c80faa
commit 02df15c460

View File

@@ -70,4 +70,30 @@ describe('CoCorrespondentsList', () => {
await expect.element(page.getByText('MM')).toBeVisible();
});
it('handles a single-word name (initials use just one letter)', async () => {
render(CoCorrespondentsList, {
props: {
coCorrespondents: [{ id: 'c-1', name: 'Cher', count: 2 }],
personId: 'p-1'
}
});
// "Cher" → initials "C"
const initialsBadge = document.querySelector('span.flex.h-4.w-4');
expect(initialsBadge?.textContent?.trim()).toBe('C');
});
it('handles a name part starting with empty string gracefully', async () => {
render(CoCorrespondentsList, {
props: {
coCorrespondents: [{ id: 'c-1', name: ' Max', count: 1 }],
personId: 'p-1'
}
});
// Leading space → name.split(' ') yields ['', '', 'Max']; first chars are '', '', 'M' → 'M'
const initialsBadge = document.querySelector('span.flex.h-4.w-4');
expect(initialsBadge?.textContent?.trim()).toContain('M');
});
});