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'); } }), ); }); });