Files
AndreaSlopFotografie/web/src/lib/bookLabel.test.ts
T
SluijsensandClaude Opus 5.5 30dab1af42 Adds the Prijzen section to the homepage
Shows the three live packages as cards with their price and what is
included. Each card links to the contact section with ?pakket=<id>, so
the contact form can preselect it. Invalid packages from the CMS are
skipped and the pakket value is only accepted when it names a package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 01:07:36 +02:00

34 lines
1.2 KiB
TypeScript

import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import { BOOK_LABEL_MAX_NAME, bookLabel } from './bookLabel';
describe('bookLabel', () => {
it('puts short names in the visible text', () => {
expect(bookLabel('Newborn')).toEqual({ visible: 'Boek Newborn' });
expect(bookLabel('Zwangerschap')).toEqual({
visible: 'Boek Zwangerschap',
});
});
it('falls back to "Boek je shoot" with a hidden name for long names', () => {
expect(bookLabel('Bruiloft en feest')).toEqual({
visible: 'Boek je shoot',
hidden: ': Bruiloft en feest',
});
});
it('always names the package and follows the length rule (invariant)', () => {
fc.assert(
fc.property(fc.string({ maxLength: 40 }), (name) => {
const label = bookLabel(name);
expect(`${label.visible}${label.hidden ?? ''}`).toContain(name);
if (name.length <= BOOK_LABEL_MAX_NAME) {
expect(label).toEqual({ visible: `Boek ${name}` });
} else {
expect(label.visible).toBe('Boek je shoot');
}
}),
);
});
});