diff options
Diffstat (limited to 'scripts/theme-studio/test-app-core.mjs')
| -rw-r--r-- | scripts/theme-studio/test-app-core.mjs | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/scripts/theme-studio/test-app-core.mjs b/scripts/theme-studio/test-app-core.mjs index 0befeb43..16202525 100644 --- a/scripts/theme-studio/test-app-core.mjs +++ b/scripts/theme-studio/test-app-core.mjs @@ -7,7 +7,7 @@ import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import { - nameToHex, buildPkgmap, packagesForExport, mergePackagesInto, effResolve, optList, + nameToHex, buildPkgmap, packagesForExport, mergePackagesInto, effResolve, optList, slugify, } from './app-core.js'; const here = fileURLToPath(new URL('.', import.meta.url)); @@ -62,7 +62,7 @@ test('buildPkgmap: Boundary — a face with no default dict still seeds blank', const m = buildPkgmap({ a: { faces: [['f', 'f']] } }, PAL); assert.deepEqual(m.a.f, { fg: null, bg: null, bold: false, italic: false, underline: false, - strike: false, inherit: null, height: 1, source: 'default', + strike: false, inherit: null, height: 1, box: null, source: 'default', }); }); @@ -117,7 +117,7 @@ test('mergePackagesInto: Normal — fills missing fields with defaults', () => { mergePackagesInto(m, { a: { f: { fg: '#112233' } } }); assert.deepEqual(m.a.f, { fg: '#112233', bg: null, bold: false, italic: false, underline: false, - strike: false, inherit: null, height: 1, source: 'user', + strike: false, inherit: null, height: 1, box: null, source: 'user', }); }); @@ -127,6 +127,23 @@ test('mergePackagesInto: Boundary — undefined pkgs is a no-op', () => { assert.deepEqual(m, { a: { f: { fg: '#000000' } } }); }); +test('slugify: Normal — spaces and punctuation collapse to single dashes', () => { + assert.equal(slugify('My Cool Theme'), 'My-Cool-Theme'); + assert.equal(slugify('dupre revised'), 'dupre-revised'); + assert.equal(slugify('keeps.dots_and-dashes'), 'keeps.dots_and-dashes'); +}); + +test('slugify: Boundary — leading/trailing junk is trimmed', () => { + assert.equal(slugify(' spaced '), 'spaced'); + assert.equal(slugify('!!!edges!!!'), 'edges'); + assert.equal(slugify(''), 'theme'); // empty falls back +}); + +test('slugify: Error — an all-disallowed name falls back to "theme"', () => { + assert.equal(slugify('!!!'), 'theme'); + assert.equal(slugify(' '), 'theme'); +}); + // Guards the one-source-of-truth contract, same as the colormath integrity test: // the page must carry app-core.js's body (sans exports) verbatim. Requires // `python3 generate.py` to have run first. |
