Files
markdown-converter/tests/main/theme-registry-bootstrap.test.js
T
amitwh eaad62d02e feat(theme-registry): bootstrap with 25 existing + 12 new themes
Registers all 37 editor themes at startup via ThemeRegistry.bootstrap.js.
Side-effect module: requiring it populates the registry from a static
THEMES array (25 existing menu themes refactored into the registry +
12 new: Catppuccin x4, one-light, tokyo-night-storm, synthwave-84,
outrun, winter-is-coming x2, solarized-dark-hc, spring-light).

Categories split: 13 light / 22 dark / 1 high-contrast / 1 seasonal
(spring-light per spec).

Snapshot test asserts exact id order, shape validity, and category
counts. Tests use jest.resetModules() + per-test requires so the
bootstrap module re-evaluates its registration loop each run.

Amit Haridas
2026-09-14 19:43:48 +05:30

100 lines
2.9 KiB
JavaScript

/**
* @jest-environment node
*
* Bootstrap snapshot — at startup, ThemeRegistry.list() returns exactly 37
* themes (25 existing menu themes + 12 new) in the expected order.
*/
const EXPECTED_IDS = [
// Existing — light
'atomonelight',
'github',
'light',
'solarized',
'gruvbox-light',
'ayu-light',
'sepia',
'paper',
'rosepine-dawn',
'concrete-light',
// Existing — dark
'dark',
'onedark',
'dracula',
'nord',
'monokai',
'material',
'gruvbox-dark',
'tokyonight',
'palenight',
'ayu-dark',
'ayu-mirage',
'oceanic-next',
'cobalt2',
'concrete-dark',
'concrete-warm',
// New — Catppuccin
'catppuccin-latte',
'catppuccin-frappe',
'catppuccin-macchiato',
'catppuccin-mocha',
// New — One Light + Tokyo Night Storm
'one-light',
'tokyo-night-storm',
// New — Synthwave / Outrun
'synthwave-84',
'outrun',
// New — Winter is Coming
'winter-is-coming-light',
'winter-is-coming-dark',
// New — Solarized HC + Spring seasonal
'solarized-dark-hc',
'spring-light',
];
describe('ThemeRegistry.bootstrap', () => {
beforeEach(() => {
// Reset module registry so both ThemeRegistry and bootstrap re-load fresh.
// Otherwise Jest's module cache returns the already-evaluated bootstrap
// (whose registration loop has already run once), leaving list() empty
// across subsequent tests.
jest.resetModules();
});
test('registers exactly 37 themes in the expected order', () => {
const ThemeRegistry = require('../../src/main/ThemeRegistry');
ThemeRegistry.clear();
require('../../src/main/ThemeRegistry.bootstrap');
expect(ThemeRegistry.list().map((t) => t.id)).toEqual(EXPECTED_IDS);
});
test('every theme has a valid shape', () => {
const ThemeRegistry = require('../../src/main/ThemeRegistry');
ThemeRegistry.clear();
require('../../src/main/ThemeRegistry.bootstrap');
for (const t of ThemeRegistry.list()) {
expect(typeof t.id).toBe('string');
expect(typeof t.label).toBe('string');
expect(['light', 'dark', 'high-contrast', 'seasonal']).toContain(t.category);
expect(typeof t.isDark).toBe('boolean');
}
});
test('expected category counts', () => {
const ThemeRegistry = require('../../src/main/ThemeRegistry');
ThemeRegistry.clear();
require('../../src/main/ThemeRegistry.bootstrap');
const counts = ThemeRegistry.list().reduce((acc, t) => {
acc[t.category] = (acc[t.category] || 0) + 1;
return acc;
}, {});
// 10 existing light + one-light + winter-is-coming-light + catppuccin-latte = 13 light (spring-light is category=seasonal)
expect(counts.light).toBe(13);
// 15 existing dark + 3 catppuccin dark + tokyo-night-storm + synthwave-84 + outrun + winter-is-coming-dark = 22 dark
expect(counts.dark).toBe(22);
expect(counts['high-contrast']).toBe(1);
// 1: spring-light (the only seasonal theme in v1)
expect(counts.seasonal).toBe(1);
});
});