test: cover ScriptTypeSelect, SinglePersonHintBar, UserGroupsSection
ScriptTypeSelect: option list, placeholder disabled, value initialisation, disabled prop propagation. SinglePersonHintBar: hasDateFilter false vs true branches, sortDir DESC vs ASC label switch, year-range with only fromDate fallback. UserGroupsSection: per-group checkbox rendering, label visibility, selectedGroupIds preselection, empty groups list, default empty selection. 15 tests across three small primitives. Refs #496. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { describe, it, expect, afterEach } from 'vitest';
|
||||
import { cleanup, render } from 'vitest-browser-svelte';
|
||||
import { page } from 'vitest/browser';
|
||||
import SinglePersonHintBar from './SinglePersonHintBar.svelte';
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
describe('SinglePersonHintBar', () => {
|
||||
it('renders the no-filter prompt when neither fromDate nor toDate is supplied', async () => {
|
||||
render(SinglePersonHintBar, { props: { senderName: 'Anna Schmidt' } });
|
||||
|
||||
await expect.element(page.getByText('Anna Schmidt')).toBeVisible();
|
||||
await expect.element(page.getByText(/wähle einen korrespondenten/i)).toBeVisible();
|
||||
});
|
||||
|
||||
it('renders the year range and sort label when fromDate is supplied', async () => {
|
||||
render(SinglePersonHintBar, {
|
||||
props: {
|
||||
senderName: 'Anna Schmidt',
|
||||
fromDate: '1923-01-01',
|
||||
toDate: '1925-12-31',
|
||||
sortDir: 'DESC'
|
||||
}
|
||||
});
|
||||
|
||||
await expect.element(page.getByText('1923–1925')).toBeVisible();
|
||||
await expect.element(page.getByText('Neueste')).toBeVisible();
|
||||
});
|
||||
|
||||
it('uses the "Älteste" label when sortDir is ASC', async () => {
|
||||
render(SinglePersonHintBar, {
|
||||
props: { senderName: 'Anna Schmidt', fromDate: '1923-01-01', sortDir: 'ASC' }
|
||||
});
|
||||
|
||||
await expect.element(page.getByText('Älteste')).toBeVisible();
|
||||
});
|
||||
|
||||
it('hides the no-filter prompt when fromDate alone is set', async () => {
|
||||
render(SinglePersonHintBar, {
|
||||
props: { senderName: 'Anna Schmidt', fromDate: '1923-01-01' }
|
||||
});
|
||||
|
||||
await expect.element(page.getByText(/wähle einen korrespondenten/i)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows year range using only fromYear when toDate is empty', async () => {
|
||||
render(SinglePersonHintBar, {
|
||||
props: { senderName: 'Anna Schmidt', fromDate: '1923-01-01' }
|
||||
});
|
||||
|
||||
await expect.element(page.getByText('1923–')).toBeVisible();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user