Files
tabs/tests/scheme.test.ts
zeekay 3182d39121 package: 0.1.15, New shell wears the terminal, and a terminal follows the theme
In the light theme the frame turns the terminal's dark palette over (lightness
flipped, hues kept) on a white ground, live and on every terminal, without
telling the machine's page anything an older machine would not hear.
2026-11-08 15:11:48 -08:00

39 lines
1.8 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { FRAME, frameFilter, schemeOf } from '@/lib/scheme';
/**
* A terminal follows the theme the page wears. The page marks its root with a
* theme class (`t_light`, `t_dark`, `light`, `dark`) or a data-theme attribute;
* with neither, the system decides.
*/
describe('the scheme a terminal wears', () => {
test('reads the root’s theme class, in either spelling', () => {
expect(schemeOf({ className: 't_light', theme: null }, true)).toBe('light');
expect(schemeOf({ className: 'light', theme: null }, true)).toBe('light');
expect(schemeOf({ className: 't_dark', theme: null }, false)).toBe('dark');
expect(schemeOf({ className: 'a dark b', theme: null }, false)).toBe('dark');
});
test('reads data-theme when the class says nothing', () => {
expect(schemeOf({ className: '', theme: 'light' }, true)).toBe('light');
expect(schemeOf({ className: '', theme: 'dark' }, false)).toBe('dark');
});
test('falls back to the system, and a word that only contains a scheme is not one', () => {
expect(schemeOf({ className: '', theme: null }, true)).toBe('dark');
expect(schemeOf({ className: '', theme: null }, false)).toBe('light');
expect(schemeOf({ className: 'twilight sunlight', theme: null }, true)).toBe('dark');
});
test('dark leaves the machine’s palette as it is; light turns it over on a white ground', () => {
expect(FRAME.dark.ground).toBe('black');
expect(frameFilter('dark', true)).toBeUndefined();
expect(FRAME.light.ground).toBe('white');
expect(frameFilter('light', true)).toBe('invert(1) hue-rotate(180deg)');
});
test('an unfocused pane is dimmed in either scheme, after the palette is turned', () => {
expect(frameFilter('dark', false)).toBe('brightness(0.65)');
expect(frameFilter('light', false)).toBe('invert(1) hue-rotate(180deg) brightness(0.94)');
});
});