Custom set difference for tests
Some checks failed
Build and Test - Staging / build_and_push (pull_request) Failing after 2s
Build and Test - Staging / test (pull_request) Successful in 16m27s
Build and Test - Staging / deploy_staging (pull_request) Successful in 3s

This commit is contained in:
2025-11-12 00:17:15 -08:00
parent ac266b98ec
commit 96151d6512

View File

@@ -2,6 +2,9 @@ import {expect, test} from "vitest";
import {siteLayout, getPaths} from "@data/site-layout.ts";
export const setDifference = <T>(a: Set<T>, b: Set<T>) =>
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"))
@@ -19,21 +22,18 @@ const siteLayoutPaths = new Set([...getPaths(siteLayout), ...getPaths(siteLayout
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);
const astroNotLayoutPaths = setDifference(astroStaticPaths, siteLayoutPaths);
expect(astroNotLayoutPaths).toHaveLength(0);
});
test('Pages Missing from Astro Paths', () => {
const siteLayoutNotAstroPaths = siteLayoutPaths.difference(astroStaticPaths);
const siteLayoutNotAstroPaths = setDifference(siteLayoutPaths, astroStaticPaths);
expect(siteLayoutNotAstroPaths).toHaveLength(0);
});