Files
AndreaSlopFotografie/web/src/lib/knowsAboutList.test.ts
T
SluijsensandClaude Opus 5.5 e15215393e Adds the Over mij page
Replaces the placeholder with the page from the design and the texts from
the live site: Andrea's introduction with her portrait, how it started,
two photos, life outside photography and a booking button. The page is
now indexed, with its own title, description, preview image and AboutPage
data about Andrea.

The portrait loads straight away instead of after the page, since on
phones it is the largest paint. Lighthouse no longer lets every indexed
page use the homepage's lower mobile performance target; it now only
applies to the homepage itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 01:17:33 +02:00

49 lines
1.7 KiB
TypeScript

import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import { knowsAboutEntries } from '@/test/arbitraries';
import { knowsAboutList } from './knowsAboutList';
describe('knowsAboutList', () => {
it('trims, drops empty entries and duplicates, keeps the first one', () => {
expect(
knowsAboutList([
' Newbornfotografie ',
'',
' ',
'Gezinsfotografie',
'Newbornfotografie',
]),
).toEqual(['Newbornfotografie', 'Gezinsfotografie']);
});
it('only keeps trimmed, non-empty, unique input entries (invariant)', () => {
fc.assert(
fc.property(knowsAboutEntries, (entries) => {
const out = knowsAboutList(entries);
const trimmed = entries.map((entry) => entry.trim());
expect(out.every((entry) => entry !== '')).toBe(true);
expect(out.every((entry) => trimmed.includes(entry))).toBe(
true,
);
expect(new Set(out).size).toBe(out.length);
// Every non-empty input entry survives, in first-seen order
expect(out).toEqual(
trimmed.filter(
(entry, index) =>
entry !== '' && trimmed.indexOf(entry) === index,
),
);
}),
);
});
it('changes nothing the second time (idempotency)', () => {
fc.assert(
fc.property(knowsAboutEntries, (entries) => {
const once = knowsAboutList(entries);
expect(knowsAboutList(once)).toEqual(once);
}),
);
});
});