aboutsummaryrefslogtreecommitdiff
path: root/scripts/theme-studio/inline-strip.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
commit497cd2bfd83131eb68a8b7f6299af810584b1f5a (patch)
tree7b2edc0a65ae1313fdb072d4a59b35deb8f1b085 /scripts/theme-studio/inline-strip.mjs
parentbe93d96a6ef7882e6871627c5e3585852a80dd0f (diff)
downloaddotemacs-497cd2bfd83131eb68a8b7f6299af810584b1f5a.tar.gz
dotemacs-497cd2bfd83131eb68a8b7f6299af810584b1f5a.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/inline-strip.mjs')
-rw-r--r--scripts/theme-studio/inline-strip.mjs15
1 files changed, 15 insertions, 0 deletions
diff --git a/scripts/theme-studio/inline-strip.mjs b/scripts/theme-studio/inline-strip.mjs
new file mode 100644
index 000000000..112d55ce6
--- /dev/null
+++ b/scripts/theme-studio/inline-strip.mjs
@@ -0,0 +1,15 @@
+// Shared by the inline-integrity tests (test-colormath.mjs, test-app-core.mjs,
+// test-app-util.mjs). Mirrors strip_exports in generate.py: drop top-level
+// export/import lines (a pure module may import a peer for its own unit tests,
+// while the inlined page copy relies on that peer already being present), then
+// rstrip. The page is asserted to carry the stripped body verbatim, so this MUST
+// stay aligned with generate.py's strip_exports -- one definition keeps the three
+// test copies from drifting apart.
+//
+// (This file matches the `*.mjs` test glob in run-tests.sh; it carries no tests,
+// so it contributes zero to the count.)
+export const stripInlinedBody = (s) =>
+ s.split('\n')
+ .filter((l) => !(l.startsWith('export') || l.startsWith('import')))
+ .join('\n')
+ .replace(/\s+$/, '');