aboutsummaryrefslogtreecommitdiff
path: root/scripts/theme-studio/test-columns.mjs
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-13 16:41:45 -0500
committerCraig Jennings <c@cjennings.net>2026-06-13 16:41:45 -0500
commita2bb7aa580dbc29e8f750cee98bec030ba1dcbce (patch)
tree8daddba2e367ca00c8e724542a3d4fab876ecb14 /scripts/theme-studio/test-columns.mjs
parent8b05b943df3e76d621020d2d5885689f0781f78d (diff)
downloaddotemacs-a2bb7aa580dbc29e8f750cee98bec030ba1dcbce.tar.gz
dotemacs-a2bb7aa580dbc29e8f750cee98bec030ba1dcbce.zip
Fix theme studio bg-like imported colors
Diffstat (limited to 'scripts/theme-studio/test-columns.mjs')
-rw-r--r--scripts/theme-studio/test-columns.mjs19
1 files changed, 18 insertions, 1 deletions
diff --git a/scripts/theme-studio/test-columns.mjs b/scripts/theme-studio/test-columns.mjs
index ab88cb73..abfab0a3 100644
--- a/scripts/theme-studio/test-columns.mjs
+++ b/scripts/theme-studio/test-columns.mjs
@@ -5,7 +5,7 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
-import { columnsFromPalette, regenColumn, rankByLightness, stepRepointPlan, sortColumns } from './app-core.js';
+import { columnsFromPalette, regenColumn, groundRoleOfEntry, rankByLightness, stepRepointPlan, sortColumns } from './app-core.js';
const columnOf = (columns, name) => columns.find(f => f.members.some(m => m.name === name));
@@ -86,6 +86,23 @@ test('columnsFromPalette: Boundary - ground entries and ground-N steps stay out
assert.ok(!columns.some(f => f.members.some(m => m.name === 'bg' || m.name === 'ground-1')));
});
+test('columnsFromPalette: Boundary - imported bg-like names are not ground just because their hex matches bg', () => {
+ const pal = [['#0d0b0a', 'bg2'], ['#0d0b0a', 'bg-alt'], ['#0d0b0a', 'bg', 'ground'], ['#f0fef0', 'fg', 'ground']];
+ const { ground, columns } = columnsFromPalette(pal, { bg: '#0d0b0a', fg: '#f0fef0' });
+ assert.deepEqual(ground.map(g => [g.role, g.name]), [['bg', 'bg'], ['fg', 'fg']]);
+ assert.ok(columnOf(columns, 'bg2'), 'bg2 remains in a normal imported color column');
+ assert.ok(columnOf(columns, 'bg-alt'), 'bg-alt remains in a normal imported color column');
+});
+
+test('groundRoleOfEntry: Boundary - exact ground roles only, not bg-prefix names', () => {
+ const ground = { bg: '#0d0b0a', fg: '#f0fef0' };
+ assert.equal(groundRoleOfEntry(['#0d0b0a', 'bg'], ground), 'bg');
+ assert.equal(groundRoleOfEntry(['#0d0b0a', 'ground'], ground), 'bg');
+ assert.equal(groundRoleOfEntry(['#0d0b0a', 'bg2'], ground), null);
+ assert.equal(groundRoleOfEntry(['#0d0b0a', 'bg-alt'], ground), null);
+ assert.equal(groundRoleOfEntry(['#444444', 'ground-1'], ground), 'step');
+});
+
// --- regenColumn ------------------------------------------------------------
test('regenColumn: Normal - n steps each side plus the base, ordered by offset', () => {