diff --git a/frontend/src/routes/persons/[id]/CoCorrespondentsList.svelte.test.ts b/frontend/src/routes/persons/[id]/CoCorrespondentsList.svelte.test.ts index 147523b6..5c9af779 100644 --- a/frontend/src/routes/persons/[id]/CoCorrespondentsList.svelte.test.ts +++ b/frontend/src/routes/persons/[id]/CoCorrespondentsList.svelte.test.ts @@ -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'); + }); });