diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-20 16:33:36 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-20 16:33:36 -0400 |
| commit | 13969c7070034c1b321998e466f9e5a128ace44c (patch) | |
| tree | f7295ab210948a20aad88fb21cdbd9af93dba354 /scripts/theme-studio/inline-strip.mjs | |
| parent | 10a567898783ba300841922fcc1d469408efb0c5 (diff) | |
| download | dotemacs-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/inline-strip.mjs')
| -rw-r--r-- | scripts/theme-studio/inline-strip.mjs | 15 |
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+$/, ''); |
