From da27189f09c185089cd77b8ea5199b66a6c031c0 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 15 Oct 2025 14:52:26 -0300 Subject: test, urls: get content-function unit test infra working, probably --- test/lib/content-function.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/lib/content-function.js b/test/lib/content-function.js index a46d18c9..49fe5c95 100644 --- a/test/lib/content-function.js +++ b/test/lib/content-function.js @@ -11,16 +11,21 @@ import {quickEvaluate} from '#content-function'; import * as html from '#html'; import {internalDefaultStringsFile, processLanguageFile} from '#language'; import {empty} from '#sugar'; -import {generateURLs, thumb, urlSpec} from '#urls'; + +import { + applyLocalizedWithBaseDirectory, + generateURLs, + internalDefaultURLSpecFile, + processURLSpecFromFileSync, + thumb, +} from '#urls'; import mock from './generic-mock.js'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); -function cleanURLSpec(reference) { - const prepared = structuredClone(reference); - - for (const spec of Object.values(prepared)) { +function cleanURLSpec(urlSpec) { + for (const spec of Object.values(urlSpec)) { if (spec.prefix) { // Strip out STATIC_VERSION. This updates fairly regularly and we // don't want it to affect snapshot tests. @@ -28,12 +33,23 @@ function cleanURLSpec(reference) { .replace(/static-\d+[a-z]\d+/i, 'static'); } } +} + +function urlsPlease() { + const {aggregate: urlsAggregate, result: urlSpec} = + processURLSpecFromFileSync(internalDefaultURLSpecFile); + + urlsAggregate.close(); + + applyLocalizedWithBaseDirectory(urlSpec); + + cleanURLSpec(urlSpec); - return prepared; + return generateURLs(urlSpec); } export function testContentFunctions(t, message, fn) { - const urls = generateURLs(cleanURLSpec(urlSpec)); + const urls = urlsPlease(); t.test(message, async t => { let loadedContentDependencies; -- cgit 1.3.0-6-gf8a5