Files
caperren-com/test/endpoints.spec.ts
Corwin Perren cef1b3381f
Some checks failed
Build and Test - Staging / test (pull_request) Failing after 3m29s
Build and Test - Staging / build_and_push (pull_request) Has been skipped
Build and Test - Staging / deploy_staging (pull_request) Has been skipped
Make endpoint tests not async and more logging
2025-11-11 23:12:45 -08:00

40 lines
1.2 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)]);
test('Astro Paths Not Empty', () => {
expect(astroStaticPaths).not.toHaveLength(0);
console.log(astroStaticPaths);
});
test('Site Layout Paths Not Empty', () => {
expect(siteLayoutPaths).not.toHaveLength(0);
console.log(siteLayoutPaths);
});
test('Pages Missing from Site Layout', () => {
const astroNotLayoutPaths = astroStaticPaths.difference(siteLayoutPaths);
expect(astroNotLayoutPaths).toHaveLength(0);
});
test('Pages Missing from Astro Paths', () => {
const siteLayoutNotAstroPaths = siteLayoutPaths.difference(astroStaticPaths);
expect(siteLayoutNotAstroPaths).toHaveLength(0);
});