diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-13 19:04:17 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-13 19:04:17 -0500 |
| commit | edf19b0c0d1a34a0aa0b54f8cbfc180b282fd348 (patch) | |
| tree | 6b60fa4fd9c84d326140092ea211440303136a0f /scripts/theme-studio/test-app-core.mjs | |
| parent | cd774c306ae8087ed7e60071458c1a81d81a3b34 (diff) | |
| download | dotemacs-edf19b0c0d1a34a0aa0b54f8cbfc180b282fd348.tar.gz dotemacs-edf19b0c0d1a34a0aa0b54f8cbfc180b282fd348.zip | |
Add theme studio face color step arrows
Diffstat (limited to 'scripts/theme-studio/test-app-core.mjs')
| -rw-r--r-- | scripts/theme-studio/test-app-core.mjs | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/scripts/theme-studio/test-app-core.mjs b/scripts/theme-studio/test-app-core.mjs index 483183050..ded3da946 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, normalizePkgFace, buildPkgmap, packagesForExport, mergePackagesInto, effResolve, optList, paletteOptionList, slugify, + nameToHex, normalizePkgFace, buildPkgmap, packagesForExport, mergePackagesInto, effResolve, optList, paletteOptionList, spanNeighborHex, slugify, clearPalettePlan, deletePaletteColumnPlan, groundColumnMembersFromPalette, areAllLocked, lockToggleLabel, toggleLockSet, } from './app-core.js'; @@ -100,6 +100,36 @@ test('paletteOptionList: Error — a cur outside palette and ground is surfaced assert.deepEqual(list[1], ['#123456', '(gone) #123456']); }); +test('spanNeighborHex: Normal — steps lighter and darker within the current column', () => { + const pal = [ + ['#222222', 'gray-dark', 'gray'], + ['#888888', 'gray-mid', 'gray'], + ['#dddddd', 'gray-light', 'gray'], + ['#330000', 'red-dark', 'red'], + ]; + const ground = { bg: '#000000', fg: '#ffffff' }; + assert.equal(spanNeighborHex('#888888', pal, ground, 1), '#dddddd'); + assert.equal(spanNeighborHex('#888888', pal, ground, -1), '#222222'); + assert.equal(spanNeighborHex('#dddddd', pal, ground, 1), null); + assert.equal(spanNeighborHex('#222222', pal, ground, -1), null); +}); + +test('spanNeighborHex: Normal — ground steps by lightness too', () => { + const pal = [ + ['#ffffff', 'bg', 'ground'], + ['#777777', 'ground+1', 'ground'], + ['#000000', 'fg', 'ground'], + ]; + const ground = { bg: '#ffffff', fg: '#000000' }; + assert.equal(spanNeighborHex('#777777', pal, ground, 1), '#ffffff'); + assert.equal(spanNeighborHex('#777777', pal, ground, -1), '#000000'); +}); + +test('spanNeighborHex: Boundary — default and gone colors cannot step', () => { + assert.equal(spanNeighborHex('', PAL, { bg: '#000000', fg: '#ffffff' }, 1), null); + assert.equal(spanNeighborHex('#123456', PAL, { bg: '#000000', fg: '#ffffff' }, 1), null); +}); + test('clearPalettePlan: Normal — removes non-ground colors and records recoverable names', () => { const plan = clearPalettePlan([ ['#0d0b0a', 'bg', 'ground'], |
