test: cover DocumentThumbnail, UnsavedWarningBanner, PersonsStatsBar
DocumentThumbnail: thumbnailUrl→img branch, no-thumbnail→placeholder icon branch, sm vs lg size container class, lazy/async loading attrs. UnsavedWarningBanner: warning text, discard button, callback wiring. PersonsStatsBar: count rendering, singular/plural label switching for both persons and documents (4 branches), zero-count plural fallback. 14 tests across three small primitive files. Refs #496. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
46
frontend/src/routes/persons/PersonsStatsBar.svelte.test.ts
Normal file
46
frontend/src/routes/persons/PersonsStatsBar.svelte.test.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { describe, it, expect, afterEach } from 'vitest';
|
||||
import { cleanup, render } from 'vitest-browser-svelte';
|
||||
import { page } from 'vitest/browser';
|
||||
import PersonsStatsBar from './PersonsStatsBar.svelte';
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
describe('PersonsStatsBar', () => {
|
||||
it('renders both counts', async () => {
|
||||
render(PersonsStatsBar, { props: { totalPersons: 42, totalDocuments: 99 } });
|
||||
|
||||
await expect.element(page.getByText('42')).toBeVisible();
|
||||
await expect.element(page.getByText('99')).toBeVisible();
|
||||
});
|
||||
|
||||
it('uses the singular person label when totalPersons is 1', async () => {
|
||||
render(PersonsStatsBar, { props: { totalPersons: 1, totalDocuments: 5 } });
|
||||
|
||||
await expect.element(page.getByText('Person', { exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
it('uses the plural person label when totalPersons is not 1', async () => {
|
||||
render(PersonsStatsBar, { props: { totalPersons: 5, totalDocuments: 5 } });
|
||||
|
||||
await expect.element(page.getByText('Personen', { exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
it('uses the singular document label when totalDocuments is 1', async () => {
|
||||
render(PersonsStatsBar, { props: { totalPersons: 5, totalDocuments: 1 } });
|
||||
|
||||
await expect.element(page.getByText('Dokument', { exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
it('uses the plural document label when totalDocuments is not 1', async () => {
|
||||
render(PersonsStatsBar, { props: { totalPersons: 5, totalDocuments: 5 } });
|
||||
|
||||
await expect.element(page.getByText('Dokumente', { exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
it('handles zero counts with plural labels', async () => {
|
||||
render(PersonsStatsBar, { props: { totalPersons: 0, totalDocuments: 0 } });
|
||||
|
||||
await expect.element(page.getByText('Personen', { exact: true })).toBeVisible();
|
||||
await expect.element(page.getByText('Dokumente', { exact: true })).toBeVisible();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user