aboutsummaryrefslogtreecommitdiff
path: root/scripts/theme-studio/test-colormath.mjs
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-20 16:33:36 -0400
committerCraig Jennings <c@cjennings.net>2026-06-20 16:33:36 -0400
commit13969c7070034c1b321998e466f9e5a128ace44c (patch)
treef7295ab210948a20aad88fb21cdbd9af93dba354 /scripts/theme-studio/test-colormath.mjs
parent10a567898783ba300841922fcc1d469408efb0c5 (diff)
downloaddotemacs-13969c7070034c1b321998e466f9e5a128ace44c.tar.gz
dotemacs-13969c7070034c1b321998e466f9e5a128ace44c.zip
refactor(theme-studio): dedup the inline-integrity test scaffolding
Two test-DRY cleanups. The seven near-identical test_page_carries_*_verbatim methods in test_generate.py collapse into one subTest loop over the inlined-body names. The strip-exports helper -- reimplemented three times across the colormath, app-core, and app-util inline-integrity tests, each annotated 'same strip generate.py applies' -- moves to one shared inline-strip.mjs (stripInlinedBody), so the three copies can no longer drift from generate.py's strip_exports.
Diffstat (limited to 'scripts/theme-studio/test-colormath.mjs')
-rw-r--r--scripts/theme-studio/test-colormath.mjs7
1 files changed, 3 insertions, 4 deletions
diff --git a/scripts/theme-studio/test-colormath.mjs b/scripts/theme-studio/test-colormath.mjs
index ee40e3437..a1ec9264e 100644
--- a/scripts/theme-studio/test-colormath.mjs
+++ b/scripts/theme-studio/test-colormath.mjs
@@ -18,9 +18,8 @@ import {
const close = (a, b, eps = 0.005) => Math.abs(a - b) <= eps;
const here = fileURLToPath(new URL('.', import.meta.url));
-// Same export-strip generate.py applies before inlining (drop `export` lines, rstrip).
-const stripExports = (s) =>
- s.split('\n').filter((l) => !l.startsWith('export')).join('\n').replace(/\s+$/, '');
+// Same strip generate.py applies before inlining (drop export/import lines, rstrip).
+import { stripInlinedBody } from './inline-strip.mjs';
test('srgb2oklab achromatic anchors', () => {
const w = srgb2oklab('#ffffff');
@@ -266,7 +265,7 @@ test('reliefColors: malformed hex returns null pair (Error)', () => {
// body (sans exports) verbatim, so the inlined copy and the tested module cannot
// drift. Requires `python3 generate.py` to have run first.
test('inline-integrity: theme-studio.html contains the colormath.js body verbatim', () => {
- const body = stripExports(readFileSync(here + 'colormath.js', 'utf8'));
+ const body = stripInlinedBody(readFileSync(here + 'colormath.js', 'utf8'));
const html = readFileSync(here + 'theme-studio.html', 'utf8');
assert.ok(html.includes(body), 'generated page is missing the colormath.js body verbatim');
});