import {expect, test} from "vitest"; import {siteLayout, getPaths} from "@data/site-layout.ts"; export const setDifference = (a: Set, b: Set) => new Set([...a].filter(x => !b.has(x))); // Paths that should be known to Astro statically const astroStaticPaths = new Set( Object.keys(import.meta.glob("/src/pages/**/*.astro")) .map((path) => path .replace("/src/pages", "") .replace(/index\.astro$/, "") .replace(/\.astro$|\.md$/, "") .replace(/\/$/, "") || "/" )); // Paths that exist in the site layout const siteLayoutPaths = new Set([...getPaths(siteLayout), ...getPaths(siteLayout, [], true)]); test('Astro Paths Not Empty', () => { expect(astroStaticPaths).not.toHaveLength(0); }); test('Site Layout Paths Not Empty', () => { expect(siteLayoutPaths).not.toHaveLength(0); }); test('Pages Missing from Site Layout', () => { const astroNotLayoutPaths = setDifference(astroStaticPaths, siteLayoutPaths); expect(astroNotLayoutPaths).toHaveLength(0); }); test('Pages Missing from Astro Paths', () => { const siteLayoutNotAstroPaths = setDifference(siteLayoutPaths, astroStaticPaths); expect(siteLayoutNotAstroPaths).toHaveLength(0); });