Files
caperren-com/test/endpoints.spec.ts

33 lines
1.1 KiB
TypeScript

import {expect, test} from "vitest";
import {siteLayout, getPaths} from "@data/site-layout.ts";
// 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)]);
// Paths that exist in Astro's static paths, but not in site layout
const astroNotLayoutPaths = astroStaticPaths.difference(siteLayoutPaths);
// Paths that exist in site layout, but not in Astro's static paths
const siteLayoutNotAstroPaths = siteLayoutPaths.difference(astroStaticPaths);
test('Pages Missing from Site Layout', async () => {
expect(astroNotLayoutPaths).toHaveLength(0);
});
test('Pages Missing from Astro Paths', async () => {
expect(siteLayoutNotAstroPaths).toHaveLength(0);
});