getAccentConfig(entry) maps each EVENT to its glyph (* / † / ⚭ / ★ / ◍), German redundant-cue label, and accent kind (REQ-007/008/018). test-factories build TimelineEntryDTO/TimelineDTO mirroring the real wire shape for component specs. Refs #779 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { getAccentConfig } from './eventCardConfig';
|
|
import type { components } from '$lib/generated/api';
|
|
|
|
type TimelineEntryDTO = components['schemas']['TimelineEntryDTO'];
|
|
|
|
function event(overrides: Partial<TimelineEntryDTO>): TimelineEntryDTO {
|
|
return {
|
|
kind: 'EVENT',
|
|
precision: 'YEAR',
|
|
derived: false,
|
|
senderName: '',
|
|
receiverName: '',
|
|
...overrides
|
|
};
|
|
}
|
|
|
|
describe('getAccentConfig', () => {
|
|
it('maps a derived birth to the * glyph and "Geburt"', () => {
|
|
const cfg = getAccentConfig(event({ derived: true, derivedType: 'BIRTH' }));
|
|
expect(cfg.glyph).toBe('*');
|
|
expect(cfg.label).toBe('Geburt');
|
|
expect(cfg.accent).toBe('derived');
|
|
});
|
|
|
|
it('maps a derived death to the † glyph and "Tod"', () => {
|
|
const cfg = getAccentConfig(event({ derived: true, derivedType: 'DEATH' }));
|
|
expect(cfg.glyph).toBe('†');
|
|
expect(cfg.label).toBe('Tod');
|
|
expect(cfg.accent).toBe('derived');
|
|
});
|
|
|
|
it('maps a derived marriage to the ⚭ glyph and "Heirat"', () => {
|
|
const cfg = getAccentConfig(event({ derived: true, derivedType: 'MARRIAGE' }));
|
|
expect(cfg.glyph).toBe('⚭');
|
|
expect(cfg.label).toBe('Heirat');
|
|
expect(cfg.accent).toBe('derived');
|
|
});
|
|
|
|
it('maps a HISTORICAL event to the world glyph and "Weltgeschehen"', () => {
|
|
const cfg = getAccentConfig(event({ type: 'HISTORICAL' }));
|
|
expect(cfg.glyph).toBe('◍');
|
|
expect(cfg.label).toBe('Weltgeschehen');
|
|
expect(cfg.accent).toBe('historical');
|
|
});
|
|
|
|
it('maps a curated PERSONAL event to the ★ glyph and "Familie"', () => {
|
|
const cfg = getAccentConfig(event({ type: 'PERSONAL', eventId: 'e-1' }));
|
|
expect(cfg.glyph).toBe('★');
|
|
expect(cfg.label).toBe('Familie');
|
|
expect(cfg.accent).toBe('curated');
|
|
});
|
|
});
|