Files
AndreaSlopFotografie/web/src/lib/richTextToPlain.test.ts
T
SluijsensandClaude Opus 5.5 e5f4348178 Adds the shoot-type pages content and SEO foundation
Five pages under /soorten-fotoshoots/<id> with draft copy awaiting
Andrea's approval (DRAFT markers), structured data (Service,
BreadcrumbList, FAQPage), sitemap and Lighthouse entries. The overview
route moves to soorten-fotoshoots/index.tsx.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 13:31:46 +01:00

34 lines
1.2 KiB
TypeScript

import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import { richText } from '../test/arbitraries';
import { richTextToPlain } from './richTextToPlain';
describe('richTextToPlain', () => {
it('reads links by their text, without adding spaces', () => {
expect(
richTextToPlain([
'Staat je vraag er niet tussen? ',
{ text: 'Stuur gerust een berichtje', to: '/contact' },
'.',
]),
).toBe('Staat je vraag er niet tussen? Stuur gerust een berichtje.');
expect(richTextToPlain([])).toBe('');
expect(richTextToPlain(['Alleen tekst'])).toBe('Alleen tekst');
});
it('is the text pieces and link texts joined, as long as they are together (invariant)', () => {
fc.assert(
fc.property(richText, (text) => {
const pieces = text.map((piece) =>
typeof piece === 'string' ? piece : piece.text,
);
const plain = richTextToPlain(text);
expect(plain).toBe(pieces.join(''));
expect(plain.length).toBe(
pieces.reduce((sum, piece) => sum + piece.length, 0),
);
}),
);
});
});