From a58d283eb0f3ee37e07eb1a9acdffcafa7fcec1c Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 10 May 2026 06:12:19 +0200 Subject: [PATCH] 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 --- .../[id]/CoCorrespondentsList.svelte.test.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) 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'); + }); });