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>
66 lines
2.3 KiB
TypeScript
66 lines
2.3 KiB
TypeScript
import fc from 'fast-check';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { canonicalUrl } from './seo';
|
|
import { sitemapXml } from './sitemap';
|
|
import sitePages, { pageList } from './sitePages';
|
|
import { routePath } from './test/arbitraries';
|
|
|
|
const base = 'https://voorbeeld.nl';
|
|
|
|
// Parse de XML terug en geef de <loc>-waarden
|
|
const locs = (xml: string) => {
|
|
const doc = new DOMParser().parseFromString(xml, 'application/xml');
|
|
expect(doc.getElementsByTagName('parsererror')).toHaveLength(0);
|
|
return [...doc.getElementsByTagName('loc')].map((el) => el.textContent);
|
|
};
|
|
|
|
const page = fc.record({ path: routePath, indexed: fc.boolean() });
|
|
|
|
describe('sitemapXml', () => {
|
|
it('contains the indexed pages', () => {
|
|
expect(locs(sitemapXml(pageList(sitePages), base))).toEqual([
|
|
`${base}/`,
|
|
`${base}/over-mij`,
|
|
`${base}/portfolio`,
|
|
`${base}/soorten-fotoshoots`,
|
|
`${base}/soorten-fotoshoots/newborn`,
|
|
`${base}/soorten-fotoshoots/zwangerschap`,
|
|
`${base}/soorten-fotoshoots/gezin`,
|
|
`${base}/soorten-fotoshoots/loveshoot`,
|
|
`${base}/soorten-fotoshoots/portret`,
|
|
`${base}/contact`,
|
|
]);
|
|
});
|
|
|
|
it('bevat precies de geindexeerde pagina, elk een keer (oracle)', () => {
|
|
fc.assert(
|
|
fc.property(fc.array(page), (pages) => {
|
|
const expected = new Set(
|
|
pages
|
|
.filter((p) => p.indexed)
|
|
.map((p) => canonicalUrl(p.path, base)),
|
|
);
|
|
const actual = locs(sitemapXml(pages, base));
|
|
expect(new Set(actual)).toEqual(expected);
|
|
expect(actual).toHaveLength(expected.size);
|
|
}),
|
|
);
|
|
});
|
|
|
|
it('blijft geldige XML met speciale tekens (round-trip)', () => {
|
|
const special = fc
|
|
.array(fc.constantFrom('a', '&', '<', '>', "'", '"', '-'), {
|
|
minLength: 1,
|
|
maxLength: 8,
|
|
})
|
|
.map((chars) => '/' + chars.join(''));
|
|
fc.assert(
|
|
fc.property(special, (path) => {
|
|
expect(
|
|
locs(sitemapXml([{ path, indexed: true }], base)),
|
|
).toEqual([canonicalUrl(path, base)]);
|
|
}),
|
|
);
|
|
});
|
|
});
|