Files
pbakaus_impeccable/tests/theme.test.mjs
T
Paul Bakaus bbed6eef08 Refresh the Impeccable product experience
Rework the landing page proof, steering demo, feature grid, slop catalog, detector coverage, theming, Live workflow, and responsive behavior.\n\nAI-assisted implementation by OpenAI Codex.
2026-07-15 23:29:47 -07:00

27 lines
691 B
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import {
getStoredPref,
nextPref,
setStoredPref,
} from '../site/scripts/utils/theme.js';
test('dark is the first-visit theme and the switcher keeps auto explicit', () => {
const values = new Map();
globalThis.localStorage = {
getItem: (key) => values.get(key) ?? null,
setItem: (key, value) => values.set(key, value),
};
assert.equal(getStoredPref(), 'dark');
assert.equal(nextPref('dark'), 'light');
assert.equal(nextPref('light'), 'auto');
assert.equal(nextPref('auto'), 'dark');
setStoredPref('auto');
assert.equal(getStoredPref(), 'auto');
delete globalThis.localStorage;
});