55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import type { EventQrInviteLayout } from '../../api';
|
|
import { buildInitialTextFields, resolveLayoutForFormat } from '../qr/utils';
|
|
|
|
describe('buildInitialTextFields', () => {
|
|
it('prefers event name for headline and default copy when customization is missing', () => {
|
|
const layoutDefaults = {
|
|
id: 'evergreen-vows',
|
|
name: 'Evergreen Vows',
|
|
description: 'Old description',
|
|
} as EventQrInviteLayout;
|
|
|
|
const fields = buildInitialTextFields({
|
|
customization: null,
|
|
layoutDefaults,
|
|
eventName: 'Sommerfest 2025',
|
|
});
|
|
|
|
expect(fields.headline).toBe('Sommerfest 2025');
|
|
expect(fields.description).toBe('Old description');
|
|
expect(fields.instructions).toHaveLength(3);
|
|
});
|
|
|
|
it('uses customization when provided', () => {
|
|
const fields = buildInitialTextFields({
|
|
customization: {
|
|
headline: 'Custom',
|
|
description: 'Desc',
|
|
instructions: ['One', 'Two'],
|
|
},
|
|
layoutDefaults: null,
|
|
eventName: 'Ignored',
|
|
});
|
|
|
|
expect(fields.headline).toBe('Custom');
|
|
expect(fields.description).toBe('Desc');
|
|
expect(fields.instructions).toEqual(['One', 'Two']);
|
|
});
|
|
});
|
|
|
|
describe('resolveLayoutForFormat', () => {
|
|
const layouts: EventQrInviteLayout[] = [
|
|
{ id: 'portrait-a4', paper: 'a4', orientation: 'portrait', panel_mode: 'single', format_hint: 'poster-a4' } as EventQrInviteLayout,
|
|
{ id: 'foldable', paper: 'a4', orientation: 'landscape', panel_mode: 'double-mirror', format_hint: 'foldable-a5' } as EventQrInviteLayout,
|
|
];
|
|
|
|
it('returns portrait layout for A4 poster', () => {
|
|
expect(resolveLayoutForFormat('a4-poster', layouts)).toBe('portrait-a4');
|
|
});
|
|
|
|
it('returns foldable layout for A5 foldable', () => {
|
|
expect(resolveLayoutForFormat('a5-foldable', layouts)).toBe('foldable');
|
|
});
|
|
});
|